

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh-CN" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh-CN" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>WeIdentity JAVA SDK文档 &mdash; weid-java-sdk version 文档</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="prev" title="WeIdentity JAVA SDK" href="../index.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> weid-java-sdk
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">WeIdentity JAVA SDK文档</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">总体介绍</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id2">术语</a></li>
<li class="toctree-l2"><a class="reference internal" href="#sdk">部署SDK</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id5">整体过程快速上手</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id6">代码结构说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id7">基本数据结构</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#weiddocument">WeIdDocument</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#tojson">1. toJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#fromjson">2. fromJson</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#challenge">Challenge</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id8">1. toJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id9">2. fromJson</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#credentialpojo">CredentialPojo</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id10">1. toJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id11">2. fromJson</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#presentationpolicye">PresentationPolicyE</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id12">1. toJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id13">2. fromJson</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#presentatione">PresentationE</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id14">1. toJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id15">2. fromJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#push">3. push</a></li>
<li class="toctree-l4"><a class="reference internal" href="#commit">4. commit</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#id16">接口简介</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id17">接口列表</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#weidservice">WeIDService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#createweid">1. createWeId</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id18">2. createWeId</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getweiddocumentjson">3. getWeIdDocumentJson</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getweiddocment">4. getWeIDDocment</a></li>
<li class="toctree-l4"><a class="reference internal" href="#setpublickey">5. setPublicKey</a></li>
<li class="toctree-l4"><a class="reference internal" href="#setservice">6. setService</a></li>
<li class="toctree-l4"><a class="reference internal" href="#setauthentication">7. setAuthentication</a></li>
<li class="toctree-l4"><a class="reference internal" href="#isweidexist">8. isWeIdExist</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#authorityissuerservice">AuthorityIssuerService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#registerauthorityissuer">1. registerAuthorityIssuer</a></li>
<li class="toctree-l4"><a class="reference internal" href="#removeauthorityissuer">2. removeAuthorityIssuer</a></li>
<li class="toctree-l4"><a class="reference internal" href="#isauthorityissuer">3. isAuthorityIssuer</a></li>
<li class="toctree-l4"><a class="reference internal" href="#queryauthorityissuerinfo">4. queryAuthorityIssuerInfo</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getallauthorityissuerlist">5. getAllAuthorityIssuerList</a></li>
<li class="toctree-l4"><a class="reference internal" href="#registerissuertype">6. registerIssuerType</a></li>
<li class="toctree-l4"><a class="reference internal" href="#addissuerintoissuertype">7. addIssuerIntoIssuerType</a></li>
<li class="toctree-l4"><a class="reference internal" href="#removeissuerfromissuertype">8. removeIssuerFromIssuerType</a></li>
<li class="toctree-l4"><a class="reference internal" href="#isspecifictypeissuer">9. isSpecificTypeIssuer</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getallspecifictypeissuerlist">10. getAllSpecificTypeIssuerList</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#cptservice">CptService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#registercpt">1. registerCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id19">2. registerCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id20">3. registerCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id21">4. registerCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#querycpt">5. queryCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#updatecpt">6. updateCpt</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id22">7. updateCpt</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#credentialservice">CredentialService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#createcredential">1. createCredential</a></li>
<li class="toctree-l4"><a class="reference internal" href="#verify">2. verify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#verifycredentialwithspecifiedpubkey">3. verifyCredentialWithSpecifiedPubKey</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getcredentialhash">4. getCredentialHash</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id23">5. getCredentialHash</a></li>
<li class="toctree-l4"><a class="reference internal" href="#addsignature">6. addSignature</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#evidenceservice">EvidenceService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#createevidence">1. createEvidence</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id24">2. createEvidence （多个签名方）</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getevidence">3. getEvidence</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id25">4. addSignature</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id26">5. verify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#sethashvalue">6. setHashValue</a></li>
<li class="toctree-l4"><a class="reference internal" href="#generatehash">7. generateHash</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#credentialpojoservice">CredentialPojoService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id27">1. createCredential</a></li>
<li class="toctree-l4"><a class="reference internal" href="#createselectivecredential">2. createSelectiveCredential</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id28">3. verify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id29">4. verify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id30">5. verify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#createpresentation">6. createPresentation</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getcredentialpojohash">7. getCredentialPojoHash</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id31">8. addSignature</a></li>
<li class="toctree-l4"><a class="reference internal" href="#createtrustedtimestamp">9. createTrustedTimestamp</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#amopservice">AmopService</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#registercallback">1. registerCallback</a></li>
<li class="toctree-l4"><a class="reference internal" href="#request">2. request</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getpolicyandchallenge">3. getPolicyAndChallenge</a></li>
<li class="toctree-l4"><a class="reference internal" href="#getencryptkey">4. getEncryptKey</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#jsontransportation">JsonTransportation</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#specify">1. specify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#serialize">2. serialize</a></li>
<li class="toctree-l4"><a class="reference internal" href="#deserialize">3. deserialize</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#qrcodetransportation">QrCodeTransportation</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id32">1. specify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id33">2. serialize</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id34">3. deserialize</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#pdftransportation">PdfTransportation</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id35">1. specify</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id36">2. serialize</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id37">3. serialize</a></li>
<li class="toctree-l4"><a class="reference internal" href="#serializewithtemplate">4. serializeWithTemplate</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id38">5. serializeWithTemplate</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id39">6. deserialize</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference external" href="https://weidentity.readthedocs.io/zh_CN/latest/">返回首页</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">weid-java-sdk</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
      <li>WeIdentity JAVA SDK文档</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/docs/weidentity-java-sdk-doc.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="weidentity-java-sdk">
<span id="weidentity-java-sdk-doc"></span><h1>WeIdentity JAVA SDK文档<a class="headerlink" href="#weidentity-java-sdk" title="永久链接至标题">¶</a></h1>
<div class="section" id="id1">
<h2>总体介绍<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
<p>WeIdentity Java SDK提供了一整套对WeIdentity进行管理操作的Java库。目前，SDK支持本地密钥管理、数字身份标识（WeIdentity DID）管理、电子凭证（WeIdentity Credential）管理、授权机构（Authority Issuer）管理、CPT（Claim Protocol Type）管理、存证（Evidence）管理、AMOP链上数据通道、凭证传输（Transportation）管理等功能，未来还将支持更丰富的功能和应用。</p>
</div>
<div class="section" id="id2">
<h2>术语<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
<ul class="simple">
<li><p>请参阅：<a class="reference external" href="https://weidentity.readthedocs.io/zh_CN/latest/docs/terminologies.html">术语表</a></p></li>
</ul>
</div>
<div class="section" id="sdk">
<h2>部署SDK<a class="headerlink" href="#sdk" title="永久链接至标题">¶</a></h2>
<ul class="simple">
<li><p><a class="reference external" href="https://weidentity.readthedocs.io/zh_CN/latest/docs/weidentity-installation.html">WeIdentity JAVA SDK 安装部署文档</a></p></li>
<li><p>开始使用之前，再次确认启动FISCO-BCOS节点已启动，确保端口可以访问。</p></li>
</ul>
</div>
<div class="section" id="id5">
<h2>整体过程快速上手<a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h2>
<p>按照以下流程可以完整地体验本SDK的核心功能：</p>
<ol class="arabic simple">
<li><p>注册DID：通过WeIdService的createWeId()生成一个WeIdentity DID并注册到链上；</p></li>
<li><p>设置DID属性：分别调用WeIdService的set方法组，为此DID设置公钥、认证方式、服务端点等属性；</p></li>
<li><p>查询DID属性：调用WeIdService的getWeIdDocumentJson()查阅生成的WeIdentity DID数据；</p></li>
<li><p>注册授权机构：通过AuthorityIssuerService的registerAuthorityIssuer()把生成的WeIdentity DID注册成一个授权机构；</p></li>
<li><p>查询授权机构：调用AuthorityIssuerService的queryAuthorityIssuerInfo()查阅生成的授权机构数据；</p></li>
<li><p>注册CPT：通过CptService的registerCpt()，通过之前生成的WeIdentity DID身份创建一个你喜欢的CPT模板；</p></li>
<li><p>查询CPT：调用CptService的queryCpt()查阅生成的CPT模板；</p></li>
<li><p>生成凭证：通过CredentialPojoService的CreateCredential()，根据CPT模板，生成一份Credential；</p></li>
<li><p>查询凭证：调用CredentialPojoService的Verify()，验证此Credential是否合法；</p></li>
<li><p>凭证存证上链：调用EvidenceService的CreateEvidence()，将之前生成的Credential生成一份Hash存证上链；</p></li>
<li><p>验证链上凭证存证：调用EvidenceService的VerifyEvidence()，和链上对比，验证Credential是否被篡改。</p></li>
</ol>
</div>
<div class="section" id="id6">
<h2>代码结构说明<a class="headerlink" href="#id6" title="永久链接至标题">¶</a></h2>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>├─ app：测试小工具
├─ config：FISCO-BCOS的合约配置
├─ constant：系统常量相关
└─ contract：通过FISCO-BCOS Web3sdk生成的合约Java接口文件
   └─ deploy: 合约部署相关
├─ exception: 异常定义
└─ protocol：接口参数相关定义
   ├─ base: 基础数据类型定义
   ├─ request: 接口入参定义
   └─ response: 接口出参定义
├─ rpc：接口定义
├─ service：接口相关实现
├─ suite：一些配套的工具
└─ util：工具类实现
</pre></div>
</div>
</div>
<div class="section" id="id7">
<h2>基本数据结构<a class="headerlink" href="#id7" title="永久链接至标题">¶</a></h2>
<div class="section" id="weiddocument">
<h3>WeIdDocument<a class="headerlink" href="#weiddocument" title="永久链接至标题">¶</a></h3>
<p><strong>属性</strong></p>
<p>com.webank.weid.protocol.base.WeIdDocument</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>created</p></td>
<td><p>Long</p></td>
<td><p>创建时间</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>updated</p></td>
<td><p>Long</p></td>
<td><p>更新时间</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>List<span class="raw-html-m2r"><PublicKeyProperty></span></p></td>
<td></td>
<td><p>列出公钥集合，见下</p></td>
</tr>
<tr class="row-even"><td><p>authentication</p></td>
<td><p>List<span class="raw-html-m2r"><AuthenticationProperty></span></p></td>
<td></td>
<td><p>认证方集合，见下</p></td>
</tr>
<tr class="row-odd"><td><p>service</p></td>
<td><p>List<span class="raw-html-m2r"><ServiceProperty></span></p></td>
<td></td>
<td><p>服务端点集合，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PublicKeyProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td><p>默认为：Secp256k1</p></td>
</tr>
<tr class="row-even"><td><p>owner</p></td>
<td><p>String</p></td>
<td><p>拥有者WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>数字公钥</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.AuthenticationProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td><p>默认为：Secp256k1</p></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.ServiceProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>serviceEndpoint</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>方法</strong></p>
<div class="section" id="tojson">
<h4>1. toJson<a class="headerlink" href="#tojson" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.WeIdDocument.toJson()
接口定义:String toJson()
接口描述: 将WeIdDocument转换成json格式的字符串。
注意：此方法转换出错会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">WeIdDocument</span> <span class="n">weIdDocument</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">getWeIdDocument</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">).</span><span class="na">getResult</span><span class="o">();</span>
<span class="n">String</span> <span class="n">weIdDocumentJson</span> <span class="o">=</span> <span class="n">weIdDocument</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>
</pre></div>
</div>
</div>
<div class="section" id="fromjson">
<h4>2. fromJson<a class="headerlink" href="#fromjson" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.WeIdDocument.fromJson(String weIdDocumentJson)
接口定义:WeIdDocument fromJson(String weIdDocumentJson)
接口描述: 将json格式的WeIdDocument转换成WeIdDocument对象。
注意：调用fromJson(String weIdDocumentJson)的入参，必须是通过调用toJson()得到的json格式的WeIdDocument字符串，否则会抛异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">WeIdDocument</span> <span class="n">weIdDocument</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">getWeIdDocument</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">).</span><span class="na">getResult</span><span class="o">();</span>
<span class="n">String</span> <span class="n">weIdDocumentJson</span> <span class="o">=</span> <span class="n">weIdDocument</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>

<span class="n">WeIdDocument</span> <span class="n">weIdDocumentFromJson</span> <span class="o">=</span> <span class="n">WeIdDocument</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">weIdDocumentJson</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="challenge">
<h3>Challenge<a class="headerlink" href="#challenge" title="永久链接至标题">¶</a></h3>
<p><strong>属性</strong></p>
<p>com.webank.weid.protocol.base.Challenge</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>policy提供给指定的WeIdentity DID</p></td>
</tr>
<tr class="row-odd"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>nonce</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>随机字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>方法</strong></p>
<div class="section" id="id8">
<h4>1. toJson<a class="headerlink" href="#id8" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.Challenge.toJson()
接口定义:String toJson()
接口描述: 将Challenge转换成json格式的字符串。
注意：此方法转换出错会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">,</span> <span class="s">&quot;1234&quot;</span><span class="o">);</span>
<span class="n">String</span> <span class="n">challengeJson</span> <span class="o">=</span> <span class="n">challenge</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>
</pre></div>
</div>
</div>
<div class="section" id="id9">
<h4>2. fromJson<a class="headerlink" href="#id9" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.Challenge.fromJson(String challengeJson)
接口定义:Challenge fromJson(String challengeJson)
接口描述: 将json格式的Challenge转换成Challenge对象。
注意：调用fromJson(String challengeJson)的入参，必须是通过调用toJson()得到的json格式的Challenge字符串，否则会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">,</span> <span class="s">&quot;1234&quot;</span><span class="o">);</span>
<span class="n">String</span> <span class="n">challengeJson</span> <span class="o">=</span> <span class="n">challenge</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>

<span class="n">Challenge</span> <span class="n">challengeFromJson</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">challengeJson</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="credentialpojo">
<h3>CredentialPojo<a class="headerlink" href="#credentialpojo" title="永久链接至标题">¶</a></h3>
<p><strong>属性</strong></p>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>方法</strong></p>
<div class="section" id="id10">
<h4>1. toJson<a class="headerlink" href="#id10" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.CredentialPojo.toJson()
接口定义:String toJson()
接口描述: 将CredentialPojo转换成json格式的字符串。
注意：此方法转换出错会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialResult</span> <span class="o">=</span>
             <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>
<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">String</span> <span class="n">credentialPojoJson</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">toJson</span><span class="o">();</span>
</pre></div>
</div>
</div>
<div class="section" id="id11">
<h4>2. fromJson<a class="headerlink" href="#id11" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.CredentialPojo.fromJson(String credentialPojoJson)
接口定义:CredentialPojo fromJson(String credentialPojoJson)
接口描述: 将json格式的CredentialPojo转换成CredentialPojo对象。
注意：调用fromJson(String credentialPojoJson)的入参，必须是通过调用toJson()得到的json格式的CredentialPojo字符串，否则会抛异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialResult</span> <span class="o">=</span>
             <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>
<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">String</span> <span class="n">credentialPojoJson</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">toJson</span><span class="o">();</span>

<span class="n">CredentialPojo</span> <span class="n">credentialPojoFromJson</span> <span class="o">=</span> <span class="n">CredentialPojo</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">credentialPojoJson</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="presentationpolicye">
<h3>PresentationPolicyE<a class="headerlink" href="#presentationpolicye" title="永久链接至标题">¶</a></h3>
<p><strong>属性</strong></p>
<p>com.webank.weid.protocol.base.PresentationPolicyE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>polcyId</p></td>
<td><p>策略编号</p></td>
</tr>
<tr class="row-odd"><td><p>orgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构编号</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>policyPublisherWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>创建policy机构的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>policy</p></td>
<td><p>Map&lt;Integer, ClaimPolicy&gt;</p></td>
<td><p>Y</p></td>
<td><p>策略配置</p></td>
<td><p>key: CPTID, value: 披露策略对象</p></td>
</tr>
<tr class="row-odd"><td><p>extra</p></td>
<td><p>Map&lt;String, String&gt;</p></td>
<td><p>N</p></td>
<td><p>扩展字段</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>方法</strong></p>
<div class="section" id="id12">
<h4>1. toJson<a class="headerlink" href="#id12" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.PresentationPolicyE.toJson()
接口定义:String toJson()
接口描述: 将PresentationPolicyE转换成json格式的字符串。
注意：此方法转换出错会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;policy.json&quot;</span><span class="o">);</span>

<span class="n">String</span> <span class="n">presentationPolicyEJson</span> <span class="o">=</span> <span class="n">presentationPolicyE</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>
</pre></div>
</div>
</div>
<div class="section" id="id13">
<h4>2. fromJson<a class="headerlink" href="#id13" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.PresentationPolicyE.fromJson(String presentationPolicyEJson)
接口定义:PresentationPolicyE fromJson(String presentationPolicyEJson)
接口描述: 将json格式的PresentationPolicyE转换成PresentationPolicyE对象。
注意：调用fromJson(String presentationPolicyEJson)的入参，必须是通过调用toJson()得到的json格式的PresentationPolicyE字符串，否则会抛异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;policy.json&quot;</span><span class="o">);</span>

<span class="n">String</span> <span class="n">presentationPolicyEJson</span> <span class="o">=</span> <span class="n">presentationPolicyE</span><span class="o">.</span><span class="na">toJson</span><span class="o">();</span>

<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyEFromJson</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">presentationPolicyEJson</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="presentatione">
<h3>PresentationE<a class="headerlink" href="#presentatione" title="永久链接至标题">¶</a></h3>
<p><strong>属性</strong></p>
<p>com.webank.weid.protocol.base.PresentationE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td><p>上下文</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td><p>Presentation Type</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>credentialList</p></td>
<td><p>List&lt;CredentialPojo&gt;</p></td>
<td><p>Y</p></td>
<td><p>凭证列表</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Presentation的签名信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>方法</strong></p>
<div class="section" id="id14">
<h4>1. toJson<a class="headerlink" href="#id14" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.PresentationE.toJson()
接口定义:String toJson()
接口描述: 将PresentationE转换成json格式的字符串。
注意：此方法转换出错会抛DATA_TYPE_CASE_ERROR异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1101</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationERes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">String</span> <span class="n">presentationEJson</span> <span class="o">=</span> <span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">toJson</span><span class="o">();</span>
</pre></div>
</div>
</div>
<div class="section" id="id15">
<h4>2. fromJson<a class="headerlink" href="#id15" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.protocol.base.PresentationE.fromJson(String presentationEJson)
接口定义:PresentationE fromJson(String challengeJson)
接口描述: 将json格式的PresentationE转换成PresentationE对象。
注意：调用fromJson(String presentationEJson)的入参，必须是通过调用toJson()得到的json格式的PresentationE字符串，否则会抛异常 。
</pre></div>
</div>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>   <span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1101</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationERes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">String</span> <span class="n">presentationEJson</span> <span class="o">=</span> <span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">toJson</span><span class="o">();</span>

<span class="n">PresentationE</span> <span class="n">presentationE</span> <span class="o">=</span> <span class="n">PresentationE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">presentationEJson</span><span class="o">);</span>
</pre></div>
</div>
</div>
<div class="section" id="push">
<h4>3. push<a class="headerlink" href="#push" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span> 接口名称: com.webank.weid.protocol.base.PresentationE.push
 接口定义: boolean push(CredentialPojo credentialPojo)
 接口描述: 将非policy里面的Credential添加到Presentation中
注意：调用 push(CredentialPojo credentialPojo) 添加完所有Credential后需要调用 commit(WeIdAuthentication weIdAuthentication) 进行重新签名，否则验证Presentation时会失败
</pre></div>
</div>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1101</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationERes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//将非policy要求的Credential添加到presentation中</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">responseNew</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>
<span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">push</span><span class="o">(</span><span class="n">responseNew</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
</div>
<div class="section" id="commit">
<h4>4. commit<a class="headerlink" href="#commit" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.protocol.base.PresentationE.commit
接口定义: boolean commit(WeIdAuthentication weIdAuthentication)
接口描述: 添加完Credential对Presentation重新签名处理了
</pre></div>
</div>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1101</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationERes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//将非policy要求的Credential添加到presentation中</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">responseNew</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>
<span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">push</span><span class="o">(</span><span class="n">responseNew</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
<span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">commit</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">)</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="id16">
<h2>接口简介<a class="headerlink" href="#id16" title="永久链接至标题">¶</a></h2>
<p>整体上，WeIdentity Java SDK包括五个主要的接口，它们分别是：WeIdService、AuthorityIssuerService、CptService、CredentialService / CredentialPojoService、EvidenceService、AmopService。</p>
<ul class="simple">
<li><p>WeIdService</p></li>
</ul>
<p>WeIdentity DID相关功能的核心接口。</p>
<p>本接口提供WeIdentity DID的创建、获取信息、设置属性等相关操作。</p>
<ul class="simple">
<li><p>AuthorityIssuerService</p></li>
</ul>
<p>在WeIdentity的整体架构中，存在着可信的“授权机构”这一角色。一般来说，授权机构特指那些广为人知的、具有一定公信力的、并且有相对频繁签发Credential需求的实体。</p>
<p>本接口提供了对这类授权签发Credential的机构的注册、移除、查询信息等操作。</p>
<ul class="simple">
<li><p>CptService</p></li>
</ul>
<p>任何凭证的签发，都需要将数据转换成已经注册的CPT (Claim Protocol Type)格式规范，也就是所谓的“标准化格式化数据”。相关机构事先需要注册好CPT，在此之后，签发机构会根据CPT提供符合格式的数据，进而进行凭证的签发。</p>
<p>本接口提供了对CPT的注册、更新、查询等操作。</p>
<ul class="simple">
<li><p>CredentialService / CredentialPojoService</p></li>
</ul>
<p>凭证签发相关功能的核心接口。</p>
<p>本接口提供凭证的签发和验证操作、Verifiable Presentation的签发和验证操作。</p>
<ul class="simple">
<li><p>EvidenceService</p></li>
</ul>
<p>凭证存证上链的相关接口。</p>
<p>本接口提供凭证的Hash存证的生成上链、链上查询及校验等操作。</p>
<ul class="simple">
<li><p>AmopService</p></li>
</ul>
<p>AMOP通讯相关接口。</p>
<p>本接口提供AMOP的请求和注册。</p>
</div>
<div class="section" id="id17">
<h2>接口列表<a class="headerlink" href="#id17" title="永久链接至标题">¶</a></h2>
<div class="section" id="weidservice">
<h3>WeIDService<a class="headerlink" href="#weidservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="createweid">
<h4>1. createWeId<a class="headerlink" href="#createweid" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.createWeId
接口定义:ResponseData&lt;CreateWeIdDataResult&gt; createWeId()
接口描述: 内部创建公私钥，并链上注册WeIdentity DID， 并返回公钥、私钥以及WeIdentity DID。
</pre></div>
</div>
<p><strong>接口入参</strong>:   无</p>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;CreateWeIdDataResult&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CreateWeIdDataResult</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.CreateWeIdDataResult</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>公钥WeIdentity DID格式字符串</p></td>
<td><p>格式: did:weid:0x………………….</p></td>
</tr>
<tr class="row-odd"><td><p>userWeIdPublicKey</p></td>
<td><p>WeIdPublicKey</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>userWeIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPublicKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>数字公钥</p></td>
<td><p>如下调用示例返回，使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>如下调用示例返回，使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_KEYPAIR_CREATE_FAILED</p></td>
<td><p>100107</p></td>
<td><p>创建密钥对失败</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥和weid不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CreateWeIdDataResult</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">createWeId</span><span class="o">();</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>输出结果如下：
result:(com.webank.weid.protocol.response.CreateWeIdDataResult)
   weId: did:weid:101:0xf4e5f96de0627960c8b91c1cc126f7b5cdeacbd0
   userWeIdPublicKey:(com.webank.weid.protocol.base.WeIdPublicKey)
   publicKey: 3140516665390655972698269231665028730625296545812754612198268107926656717368563044260511639762256438305037318801307432426840176526241566631412406151716674
   userWeIdPrivateKey:(com.webank.weid.protocol.base.WeIdPrivateKey)
   privateKey: 70694712486452850283637015242845250545254342779640874305734061338958342229003
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30005
   transactionHash: 0x7e4fcacdd296f10936e53d64c7d6470dd4ffa52e22405c86ed8f72389419821f
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <script>mermaid.initialize({startOnLoad:true});</script><div class="mermaid">
            sequenceDiagram
调用者-&gt;&gt;WeIdentity SDK: 调用CreateWeID()
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 创建公私钥对
WeIdentity SDK-&gt;&gt;区块链节点: 调用智能合约
区块链节点-&gt;&gt;区块链节点: 以事件的方式记录created属性和public key属性
区块链节点-&gt;&gt;区块链节点: 记录当前的最新块高
区块链节点--&gt;&gt;WeIdentity SDK: 创建成功
WeIdentity SDK--&gt;&gt;调用者:新创建好的WeIdentity DID以及公私钥对
        </div></div>
<hr class="docutils" />
<div class="section" id="id18">
<h4>2. createWeId<a class="headerlink" href="#id18" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.createWeId
接口定义:ResponseData&lt;String&gt; createWeId(CreateWeIdArgs createWeIdArgs)
接口描述: 根据传入的公私钥，链上注册WeIdentity DID，并返回WeIdentity DID。
</pre></div>
</div>
<p><strong>接口入参</strong>:  com.webank.weid.protocol.request.CreateWeIdArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>数字公钥</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>后期鉴权使用</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>公钥WeIdentity DID格式字符串</p></td>
<td><p>如：did:weid:0x………………….</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PUBLICKEY_INVALID</p></td>
<td><p>100102</p></td>
<td><p>公钥无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_ALREADY_EXIST</p></td>
<td><p>100105</p></td>
<td><p>WeIdentity DID已存在</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥不与WeIdentity DID所对应</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PUBLICKEY_AND_PRIVATEKEY_NOT_MATCHED</p></td>
<td><p>100108</p></td>
<td><p>公私钥不成对</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>

<span class="n">CreateWeIdArgs</span> <span class="n">createWeIdArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateWeIdArgs</span><span class="o">();</span>
<span class="n">createWeIdArgs</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span>
   <span class="s">&quot;2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;7581560237967740187496354914151086729152742173850631851769274217992481997665&quot;</span><span class="o">);</span>

<span class="n">createWeIdArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">createWeId</span><span class="o">(</span><span class="n">createWeIdArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>输出结果如下：
result: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30007
   transactionHash: 0x7f9e0fe2bcb0e77bad9aa5c38f8440e71a48dc29406d9ad43e12130afd211c67
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
Note over 调用者:传入自己的WeIdentity DID及用作authentication的私钥
调用者-&gt;&gt;WeIdentity SDK:调用CreateWeID()
WeIdentity SDK-&gt;&gt;区块链节点:调用智能合约
区块链节点-&gt;&gt;区块链节点: 检查调用者的身份是否和WeIdentity DID匹配
opt 身份校验不通过
区块链节点--&gt;&gt;WeIdentity SDK:报错，提示私钥不匹配并退出
WeIdentity SDK--&gt;&gt;调用者:报错退出
end
区块链节点-&gt;&gt;区块链节点 : 以事件的方式记录created属性和public key属性
区块链节点-&gt;&gt;区块链节点 : 记录当前的最新块高
区块链节点--&gt;&gt;WeIdentity SDK: 创建成功
WeIdentity SDK--&gt;&gt;调用者:新创建好的WeIdentity DID
        </div></div>
<hr class="docutils" />
<div class="section" id="getweiddocumentjson">
<h4>3. getWeIdDocumentJson<a class="headerlink" href="#getweiddocumentjson" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocumentJson
接口定义:ResponseData&lt;String&gt; getWeIdDocumentJson(String weId)
接口描述: 根据WeIdentity DID查询WeIdentity DID Document信息，并以JSON格式返回。
</pre></div>
</div>
<p><strong>接口入参</strong>:   String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>weidDocument Json</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">getWeIdDocumentJson</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result: {&quot;@context&quot; : &quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;,
   &quot;id&quot; : &quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;,
   &quot;created&quot; : 1560419409898,
   &quot;updated&quot; : 1560419409898,
   &quot;publicKey&quot; : [ {
      &quot;id&quot; : &quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0&quot;,
      &quot;type&quot; : &quot;Secp256k1&quot;,
      &quot;owner&quot; : &quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;,
      &quot;publicKey&quot; : &quot;2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592&quot;
   } ],
   &quot;authentication&quot; : [ {
      &quot;type&quot; : &quot;Secp256k1&quot;,
      &quot;publicKey&quot; : &quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0&quot;
   } ],
   &quot;service&quot; : [ {
      &quot;type&quot; : &quot;drivingCardService&quot;,
      &quot;serviceEndpoint&quot; : &quot;https://weidentity.webank.com/endpoint/xxxxx&quot;
   } ]
}
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>
<p>（同时也包含getWeIDDocment时序）</p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
调用者-&gt;&gt;WeIdentity SDK : 传入指定的WeIdentity DID
WeIdentity SDK-&gt;&gt;区块链节点: 调用智能合约
区块链节点-&gt;&gt;区块链节点: 查找记录该WeIdentity DID关联的属性事件最后一次更新时的块高
区块链节点--&gt;&gt;WeIdentity SDK: 返回
loop 解析事件
WeIdentity SDK-&gt;&gt;区块链节点: 根据块高，过滤该区块里的属性事件
区块链节点--&gt;&gt;WeIdentity SDK: 返回
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 根据块高，获取到对应区块所有交易
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 根据交易获取交易回执
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 根据交易回执过滤跟当前WeIdentity DID相关的属性事件
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 根据不同的key，解析public key, authentication, service endpoint
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 组装WeIdentity Document
WeIdentity SDK-&gt;&gt;WeIdentity SDK: 根据当前事件找到上一个事件对应的块高
end
WeIdentity SDK--&gt;&gt;调用者:返回WeIdentity Document
        </div></div>
<hr class="docutils" />
<div class="section" id="getweiddocment">
<h4>4. getWeIDDocment<a class="headerlink" href="#getweiddocment" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocument
接口定义:ResponseData&lt;WeIdDocument&gt; getWeIdDocument(String weId)
接口描述: 根据WeIdentity DID查询出WeIdentity DID Document对象。
</pre></div>
</div>
<p><strong>接口入参</strong>:  String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;WeIdDocument&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>WeIdDocument</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdDocument</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>created</p></td>
<td><p>Long</p></td>
<td><p>创建时间</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>updated</p></td>
<td><p>Long</p></td>
<td><p>更新时间</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>List<span class="raw-html-m2r"><PublicKeyProperty></span></p></td>
<td></td>
<td><p>列出公钥集合，见下</p></td>
</tr>
<tr class="row-even"><td><p>authentication</p></td>
<td><p>List<span class="raw-html-m2r"><AuthenticationProperty></span></p></td>
<td></td>
<td><p>认证方集合，见下</p></td>
</tr>
<tr class="row-odd"><td><p>service</p></td>
<td><p>List<span class="raw-html-m2r"><ServiceProperty></span></p></td>
<td></td>
<td><p>服务端点集合，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PublicKeyProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td><p>默认为：Secp256k1</p></td>
</tr>
<tr class="row-even"><td><p>owner</p></td>
<td><p>String</p></td>
<td><p>拥有者WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>数字公钥</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.AuthenticationProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td><p>默认为：Secp256k1</p></td>
</tr>
<tr class="row-odd"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.ServiceProperty</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>类型</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>serviceEndpoint</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">WeIdDocument</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">getWeIdDocument</span><span class="o">(</span><span class="s">&quot;did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result:(com.webank.weid.protocol.base.WeIdDocument)
   id: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
   created: 1560419409898
   updated: 1560419409898
   publicKey:(java.util.ArrayList)
      [0]:com.webank.weid.protocol.base.PublicKeyProperty
         id: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0
         type: Secp256k18
         owner: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a
         publicKey: 2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592
   authentication:(java.util.ArrayList)
      [0]:com.webank.weid.protocol.base.AuthenticationProperty
         type: Secp256k1
         publicKey: did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0
   service:(java.util.ArrayList)
      [0]:com.webank.weid.protocol.base.ServiceProperty
         type: drivingCardService
         serviceEndpoint: https://weidentity.webank.com/endpoint/8377464
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="setpublickey">
<h4>5. setPublicKey<a class="headerlink" href="#setpublickey" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.setPublicKey
接口定义:ResponseData&lt;Boolean&gt; setPublicKey(SetPublicKeyArgs setPublicKeyArgs)
接口描述: 根据WeIdentity DID添加公钥。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.request.SetPublicKeyArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID格式字符串</p></td>
<td><p>如：did:weid:1:0x….</p></td>
</tr>
<tr class="row-odd"><td><p>owner</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>所有者</p></td>
<td><p>默认为当前WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>数字公钥</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>userWeIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，后期鉴权使用，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否set成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥不与WeIdentity DID所对应</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>

<span class="n">SetPublicKeyArgs</span> <span class="n">setPublicKeyArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SetPublicKeyArgs</span><span class="o">();</span>
<span class="n">setPublicKeyArgs</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">setPublicKeyArgs</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span>
   <span class="s">&quot;13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">setPublicKeyArgs</span><span class="o">.</span><span class="na">setUserWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span><span class="n">setPublicKeyArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30011
   transactionHash: 0xda4a1c64a3991170975475fdd6604bb2897512948ea491d3c88f24c4c3fd0028
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
Note over 调用者:传入自己的WeIdentity DID及用作authentication的公私钥
调用者-&gt;&gt;WeIdentity SDK : 调用setPublicKey来添加公钥。
WeIdentity SDK-&gt;&gt;WeIdentity SDK:拿私钥来重新加载合约对象
WeIdentity SDK-&gt;&gt;区块链节点: 调用智能合约
区块链节点-&gt;&gt;区块链节点: 检查调用者的身份是否和WeIdentity DID匹配
opt 身份校验不通过
区块链节点--&gt;&gt;WeIdentity SDK:报错，提示私钥不匹配并退出
WeIdentity SDK--&gt;&gt;调用者:报错退出
end
区块链节点-&gt;&gt;区块链节点:将公钥和WeIdentity DID以及上次记录的块高写到属性事件中
区块链节点-&gt;&gt;区块链节点:记录最新块高
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="setservice">
<h4>6. setService<a class="headerlink" href="#setservice" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.setService
接口定义:ResponseData&lt;Boolean&gt; setService(SetServiceArgs setServiceArgs)
接口描述: 根据WeIdentity DID添加Service信息。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.request.SetServiceArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID格式字符串</p></td>
<td><p>如：did:weid:101:0x…..</p></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>类型</p></td>
<td><p>如：drivingCardService</p></td>
</tr>
<tr class="row-even"><td><p>serviceEndpoint</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>服务端点</p></td>
<td><p>如：”<a class="reference external" href="https://weidentity.webank.com/endpoint/8377464">https://weidentity.webank.com/endpoint/8377464</a>”</p></td>
</tr>
<tr class="row-odd"><td><p>userWeIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，后期鉴权使用，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否set成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥不与WeIdentity DID所对应</p></td>
</tr>
<tr class="row-even"><td><p>WEID_SERVICE_TYPE_OVERLIMIT</p></td>
<td><p>100110</p></td>
<td><p>type字段超长</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>

<span class="n">SetServiceArgs</span> <span class="n">setServiceArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SetServiceArgs</span><span class="o">();</span>
<span class="n">setServiceArgs</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">setServiceArgs</span><span class="o">.</span><span class="na">setType</span><span class="o">(</span><span class="s">&quot;drivingCardService&quot;</span><span class="o">);</span>
<span class="n">setServiceArgs</span><span class="o">.</span><span class="na">setServiceEndpoint</span><span class="o">(</span><span class="s">&quot;https://weidentity.webank.com/endpoint/8377464&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">setServiceArgs</span><span class="o">.</span><span class="na">setUserWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">setService</span><span class="o">(</span><span class="n">setServiceArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30012
   transactionHash: 0xf4992c4d190a9338f13119125861aaa3fa86622de1ab6862d06c05c6e6d1d9be
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
Note over 调用者:传入自己的WeIdentity DID及要用作&lt;br&gt;authentication的私钥，&lt;br&gt;以及service endpoint
调用者-&gt;&gt;WeIdentity SDK : 调用setAuthentication来添加认证。
WeIdentity SDK-&gt;&gt;WeIdentity SDK:拿私钥来重新加载合约对象
WeIdentity SDK-&gt;&gt;区块链节点: 调用智能合约
区块链节点-&gt;&gt;区块链节点: 检查调用者的身份是否和WeIdentity DID匹配
opt 身份校验不通过
区块链节点--&gt;&gt;WeIdentity SDK:报错，提示私钥不匹配并退出
WeIdentity SDK--&gt;&gt;调用者:报错退出
end
区块链节点-&gt;&gt;区块链节点:将service endpoint和WeIdentity DID以及上次记录的块高写到属性事件中
区块链节点-&gt;&gt;区块链节点:记录最新块高
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="setauthentication">
<h4>7. setAuthentication<a class="headerlink" href="#setauthentication" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.setAuthentication
接口定义:ResponseData&lt;Boolean&gt; setAuthentication(SetAuthenticationArgs setAuthenticationArgs)
接口描述: 根据WeIdentity DID添加认证者。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.request.SetAuthenticationArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID格式字符串</p></td>
<td><p>如：did:weid:101:0x….</p></td>
</tr>
<tr class="row-odd"><td><p>owner</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>所有者</p></td>
<td><p>默认为当前WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>数字公钥</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>userWeIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，后期鉴权使用，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否set成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥不与WeIdentity DID所对应</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>其他错误</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>

<span class="n">SetAuthenticationArgs</span> <span class="n">setAuthenticationArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">SetAuthenticationArgs</span><span class="o">();</span>
<span class="n">setAuthenticationArgs</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">setAuthenticationArgs</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span>
   <span class="s">&quot;13161444623157635919577071263152435729269604287924587017945158373362984739390835280704888860812486081963832887336483721952914804189509503053687001123007342&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">setAuthenticationArgs</span><span class="o">.</span><span class="na">setUserWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">setAuthentication</span><span class="o">(</span><span class="n">setAuthenticationArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30013
   transactionHash: 0xfbf8338e7df2af0612eca5107c0d2ed75dfd7a795988687f49c010112678f847
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
Note over 调用者:传入自己的WeIdentity DID及用作authentication的公私钥
调用者-&gt;&gt;WeIdentity SDK : 调用setAuthentication来添加认证。
WeIdentity SDK-&gt;&gt;WeIdentity SDK:拿私钥来重新加载合约对象
WeIdentity SDK-&gt;&gt;区块链节点: 调用智能合约
区块链节点-&gt;&gt;区块链节点: 检查调用者的身份是否和WeIdentity DID匹配
opt 身份校验不通过
区块链节点--&gt;&gt;WeIdentity SDK:报错，提示私钥不匹配并退出
WeIdentity SDK--&gt;&gt;调用者:报错退出
end
区块链节点-&gt;&gt;区块链节点:将authentication和WeIdentity DID以及上次记录的块高写到属性事件中
区块链节点-&gt;&gt;区块链节点:记录最新块高
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="isweidexist">
<h4>8. isWeIdExist<a class="headerlink" href="#isweidexist" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.WeIdService.isWeIdExist
接口定义:ResponseData&lt;Boolean&gt; isWeIdExist(String weId)
接口描述: 根据WeIdentity DID判断链上是否存在。
</pre></div>
</div>
<p><strong>接口入参</strong>:   String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID格式字符串</p></td>
<td><p>如：did:weid:101:0x….</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否set成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdService</span> <span class="n">weIdService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">weIdService</span><span class="o">.</span><span class="na">isWeIdExist</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如下：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<hr class="docutils" />
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
      调用者-&gt;&gt;WeIdentity SDK : 传入WeIdentity DID，调用isWeIdExist来判断是否存在。
opt 参数校验
Note over WeIdentity SDK:非空检查和有效性检查
WeIdentity SDK-&gt;&gt;WeIdentity SDK:报错，提示参数不合法并退出
end
WeIdentity SDK-&gt;&gt;区块链节点: 传入WeIdentity DID链上存在性校验
      区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
</div>
<hr class="docutils" />
<div class="section" id="authorityissuerservice">
<h3>AuthorityIssuerService<a class="headerlink" href="#authorityissuerservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="registerauthorityissuer">
<h4>1. registerAuthorityIssuer<a class="headerlink" href="#registerauthorityissuer" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.AuthorityIssuerService.registerAuthorityIssuer
接口定义:ResponseData&lt;Boolean&gt; registerAuthorityIssuer(RegisterAuthorityIssuerArgs args)
接口描述: 注册成为权威机构。
注意：这是一个需要权限的操作，目前只有合约的部署者（一般为SDK）才能正确执行。
</pre></div>
</div>
<p><strong>接口入参</strong>: com.webank.weid.protocol.request.RegisterAuthorityIssuerArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>authorityIssuer</p></td>
<td><p>AuthorityIssuer</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>AuthorityIssuer信息，见下</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.AuthorityIssuer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>name</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构名称</p></td>
<td><p>机构名称必须小于32个字节，非空，且仅包含ASCII码可打印字符（ASCII值位于32~126）</p></td>
</tr>
<tr class="row-even"><td><p>created</p></td>
<td><p>Long</p></td>
<td><p>N</p></td>
<td><p>创建日期</p></td>
<td><p>注册时不需要传入，SDK内置默认为当前时间</p></td>
</tr>
<tr class="row-odd"><td><p>accValue</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权方累积判定值</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:     com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL</p></td>
<td><p>100202</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_OPCODE_MISMATCH</p></td>
<td><p>100205</p></td>
<td><p>操作码不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_NAME_ILLEGAL</p></td>
<td><p>100206</p></td>
<td><p>名称格式非法</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ACCVALUE_ILLEAGAL</p></td>
<td><p>100207</p></td>
<td><p>累计值格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>

<span class="n">AuthorityIssuer</span> <span class="n">authorityIssuer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuer</span><span class="o">();</span>
<span class="n">authorityIssuer</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">authorityIssuer</span><span class="o">.</span><span class="na">setName</span><span class="o">(</span><span class="s">&quot;webank1&quot;</span><span class="o">);</span>
<span class="n">authorityIssuer</span><span class="o">.</span><span class="na">setAccValue</span><span class="o">(</span><span class="s">&quot;0&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;36162289879206412028682370838615850457668262092955617990245744195910144330785&quot;</span><span class="o">);</span>

<span class="n">RegisterAuthorityIssuerArgs</span> <span class="n">registerAuthorityIssuerArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">RegisterAuthorityIssuerArgs</span><span class="o">();</span>
<span class="n">registerAuthorityIssuerArgs</span><span class="o">.</span><span class="na">setAuthorityIssuer</span><span class="o">(</span><span class="n">authorityIssuer</span><span class="o">);</span>
<span class="n">registerAuthorityIssuerArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">registerAuthorityIssuer</span><span class="o">(</span><span class="n">registerAuthorityIssuerArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 29963
   transactionHash: 0x97a5cc2f4f7888e788a22e7c9bef1a293614bceec4721810511d07fc5b748f33
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant WeIdService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: 调用RegisterAuthorityIssuer()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;WeIdService: 查询WeIdentity DID存在性
WeIdService-&gt;&gt;区块链节点: 链上查询WeIdentity DID属性
区块链节点--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;AuthorityIssuerService: 返回查询结果
opt 在链上不存在
AuthorityIssuerService--&gt;&gt;调用者: 报错并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 加载私钥，调用注册合约
opt 身份校验
Note over 区块链节点: 如果传入WeIdentity DID在链上不存在
区块链节点-&gt;&gt;区块链节点: 报错并退出
end
区块链节点-&gt;&gt;区块链节点: 权限检查，执行合约写入AuthorityIssuer信息
区块链节点--&gt;&gt;AuthorityIssuerService: 返回合约执行结果
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 解析合约事件
opt 失败，地址无效或无权限
AuthorityIssuerService--&gt;&gt;调用者: 报错并退出
end
AuthorityIssuerService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="removeauthorityissuer">
<h4>2. removeAuthorityIssuer<a class="headerlink" href="#removeauthorityissuer" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.AuthorityIssuerService.removeAuthorityIssuer
接口定义:ResponseData&lt;Boolean&gt; removeAuthorityIssuer(RemoveAuthorityIssuerArgs args)
接口描述: 注销权威机构。
注意：这是一个需要权限的操作，目前只有合约的部署者（一般为SDK）才能正确执行。
</pre></div>
</div>
<p><strong>接口入参</strong>:  com.webank.weid.protocol.request.RemoveAuthorityIssuerArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>授权机构WeIdentity DID</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:     com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL</p></td>
<td><p>100202</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_OPCODE_MISMATCH</p></td>
<td><p>100205</p></td>
<td><p>操作码不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;36162289879206412028682370838615850457668262092955617990245744195910144330785&quot;</span><span class="o">);</span>

<span class="n">RemoveAuthorityIssuerArgs</span> <span class="n">removeAuthorityIssuerArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">RemoveAuthorityIssuerArgs</span><span class="o">();</span>
<span class="n">removeAuthorityIssuerArgs</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">removeAuthorityIssuerArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">removeAuthorityIssuer</span><span class="o">(</span><span class="n">removeAuthorityIssuerArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29951
   transactionHash: 0xb9a2ef2a6045e0804b711e0ce39f7187de08e329160d5a5a00a1815e067f15e5
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: 调用RemoverAuthorityIssuer()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 加载交易私钥，调用移除合约
区块链节点-&gt;&gt;区块链节点: 权限检查，执行合约删除WeIdentity DID信息
区块链节点--&gt;&gt;AuthorityIssuerService: 返回合约执行结果
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 解析合约事件
opt 失败，地址无效或无权限
AuthorityIssuerService--&gt;&gt;调用者: 报错并退出
end
AuthorityIssuerService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="isauthorityissuer">
<h4>3. isAuthorityIssuer<a class="headerlink" href="#isauthorityissuer" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.AuthorityIssuerService.isAuthorityIssuer
接口定义:ResponseData&lt;Boolean&gt; isAuthorityIssuer(String weId)
接口描述: 根据WeIdentity DID判断是否为权威机构。
</pre></div>
</div>
<p><strong>接口入参</strong>:    String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>用于搜索权限发布者</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:     com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_CONTRACT_ERROR_NOT_EXISTS</p></td>
<td><p>500202</p></td>
<td><p>实体不存在</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">;</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">isAuthorityIssuer</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: 调用IsAuthorityIssuer()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用查询是否为授权机构合约
区块链节点-&gt;&gt;区块链节点: 执行合约通过WeIdentity DID查询
区块链节点--&gt;&gt;AuthorityIssuerService: 返回查询结果
AuthorityIssuerService--&gt;&gt;调用者: 返回是/否
        </div></div>
<hr class="docutils" />
<div class="section" id="queryauthorityissuerinfo">
<h4>4. queryAuthorityIssuerInfo<a class="headerlink" href="#queryauthorityissuerinfo" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.AuthorityIssuerService.queryAuthorityIssuerInfo
接口定义:ResponseData&lt;AuthorityIssuer&gt; queryAuthorityIssuerInfo(String weId)
接口描述: 根据WeIdentity DID查询权威机构信息。
</pre></div>
</div>
<p><strong>接口入参</strong>:    String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>用于搜索权限发布者</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;AuthorityIssuer&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>AuthorityIssuer</p></td>
<td></td>
<td><p>授权机构信息，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.AuthorityIssuer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>name</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构名称</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>created</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>accValue</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权方累积判定值</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>注意</strong>：因为Solidity 0.4.4的限制，无法正确的返回accValue，因此这里取得的accValue一定为空字符串。未来会进行修改。</p>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_CONTRACT_ERROR_NOT_EXISTS</p></td>
<td><p>500202</p></td>
<td><p>实体不存在</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">;</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">AuthorityIssuer</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">queryAuthorityIssuerInfo</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
result:(com.webank.weid.protocol.base.AuthorityIssuer)
   weId: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
   name: webank1
   created: 1560412556901
   accValue:
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: 调用queryAuthorityIssuerInfo()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用查询详细信息合约
区块链节点-&gt;&gt;区块链节点: 执行合约通过WeIdentity DID查询
区块链节点--&gt;&gt;AuthorityIssuerService: 返回查询结果
AuthorityIssuerService--&gt;&gt;调用者: 返回查询结果（非授权机构则无）
        </div></div>
<hr class="docutils" />
<div class="section" id="getallauthorityissuerlist">
<h4>5. getAllAuthorityIssuerList<a class="headerlink" href="#getallauthorityissuerlist" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.getAllAuthorityIssuerList
接口定义: ResponseData&lt;List&lt;AuthorityIssuer&gt;&gt; getAllAuthorityIssuerList(Integer index, Integer num)
接口描述: 查询指定范围内的issuer列表。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>index</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>检索的开始位置</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>num</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>检索的数据条数</p></td>
<td><p>单次最多可以检索50条</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;List&lt;AuthorityIssuer&gt;&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>List&lt;AuthorityIssuer&gt;</p></td>
<td></td>
<td><p>授权机构信息，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.AuthorityIssuer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>name</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权机构名称</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>created</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>accValue</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>授权方累积判定值</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>注意</strong>：因为Solidity 0.4.4的限制，无法正确的返回accValue，因此这里取得的accValue一定为空字符串。未来会进行修改。</p>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">AuthorityIssuer</span><span class="o">&gt;&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">getAllAuthorityIssuerList</span><span class="o">(</span><span class="mi">0</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
result: (java.util.ArrayList)
   [0]: com.webank.weid.protocol.base.AuthorityIssuer
      weId: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
      name: webank1
      created: 1560412556901
      accValue:
   [1]: com.webank.weid.protocol.base.AuthorityIssuer
      weId: did:weid:101:0x48f56f6b8cd77409447014ceb060243b914cb2a9
      name: webank2
      created: 1560632118000
      accValue:
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: getAllAuthorityIssuerList()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用查询详细信息合约
区块链节点-&gt;&gt;区块链节点: 执行合约查询指定数目的授权机构，打包返回结果
区块链节点--&gt;&gt;AuthorityIssuerService: 返回查询结果
AuthorityIssuerService--&gt;&gt;调用者: 返回查询结果
        </div></div>
<hr class="docutils" />
<div class="section" id="registerissuertype">
<h4>6. registerIssuerType<a class="headerlink" href="#registerissuertype" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.registerIssuerType
接口定义: ResponseData&lt;Boolean&gt; registerIssuerType(WeIdAuthentication callerAuth, String issuerType)
接口描述: 指定并注册不同issuer的类型，如学校、政府机构等。
权限说明：本方法对传入的WeIdAuthentication没有特定权限要求。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>callerAuth</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>weId身份信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuerType</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构类型</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否注册成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-even"><td><p>SPECIFIC_ISSUER_TYPE_ILLEGAL</p></td>
<td><p>100208</p></td>
<td><p>机构类型非法</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
      <span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">AuthorityIssuer</span><span class="o">&gt;&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">registerIssuerType</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">,</span> <span class="s">&quot;College&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
result: true
errorCode: 0
errorMessage: success
transactionInfo: (com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29950
       transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
       transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: registerIssuerType()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用注册授权机构类型合约
区块链节点-&gt;&gt;区块链节点: 执行合约注册授权机构类型
区块链节点--&gt;&gt;AuthorityIssuerService: 返回执行结果
AuthorityIssuerService--&gt;&gt;调用者: 返回执行结果
        </div></div>
<hr class="docutils" />
<div class="section" id="addissuerintoissuertype">
<h4>7. addIssuerIntoIssuerType<a class="headerlink" href="#addissuerintoissuertype" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.addIssuerIntoIssuerType
接口定义: ResponseData&lt;Boolean&gt; addIssuerIntoIssuerType(WeIdAuthentication callerAuth, String issuerType, String targetIssuerWeId)
接口描述: 向指定的issuerType中添加成员。
权限说明：方法的调用者至少需要是Authority Issuer才能成功。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>callerAuth</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>weId身份信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuerType</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构类型</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>targetIssuerWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer的WeIdentity DID</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否添加成员成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100201</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL</p></td>
<td><p>100202</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>SPECIFIC_ISSUER_TYPE_ILLEGAL</p></td>
<td><p>100208</p></td>
<td><p>机构类型非法</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
      <span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">AuthorityIssuer</span><span class="o">&gt;&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">addIssuerIntoIssuerType</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">,</span> <span class="s">&quot;College&quot;</span><span class="o">,</span> <span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
result: true
errorCode: 0
errorMessage: success
transactionInfo: (com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29950
       transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
       transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: addIssuerIntoIssuerType()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用添加授权机构合约
区块链节点-&gt;&gt;区块链节点: 执行合约添加授权机构
区块链节点--&gt;&gt;AuthorityIssuerService: 返回执行结果
AuthorityIssuerService--&gt;&gt;调用者: 返回执行结果
        </div></div>
<hr class="docutils" />
<div class="section" id="removeissuerfromissuertype">
<h4>8. removeIssuerFromIssuerType<a class="headerlink" href="#removeissuerfromissuertype" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.removeIssuerFromIssuerType
接口定义: ResponseData&lt;Boolean&gt; removeIssuerFromIssuerType(WeIdAuthentication callerAuth, String issuerType, String targetIssuerWeId)
接口描述: 移除指定issuerType里面的WeId成员。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>callerAuth</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>weId身份信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuerType</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构类型</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>targetIssuerWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer的WeIdentity DID</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否移除成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100201</p></td>
<td><p>无效的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_PRIVATE_KEY_ILLEGAL</p></td>
<td><p>100202</p></td>
<td><p>私钥格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>SPECIFIC_ISSUER_TYPE_ILLEGAL</p></td>
<td><p>100208</p></td>
<td><p>机构类型非法</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
      <span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">AuthorityIssuer</span><span class="o">&gt;&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">removeIssuerFromIssuerType</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">,</span> <span class="s">&quot;College&quot;</span><span class="o">,</span> <span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
result: true
errorCode: 0
errorMessage: success
transactionInfo: (com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29950
       transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
       transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: removeIssuerIntoIssuerType()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用移除授权机构合约
区块链节点-&gt;&gt;区块链节点: 执行合约移除授权机构
区块链节点--&gt;&gt;AuthorityIssuerService: 返回执行结果
AuthorityIssuerService--&gt;&gt;调用者: 返回执行结果
        </div></div>
<hr class="docutils" />
<div class="section" id="isspecifictypeissuer">
<h4>9. isSpecificTypeIssuer<a class="headerlink" href="#isspecifictypeissuer" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.isSpecificTypeIssuer
接口定义: ResponseData&lt;Boolean&gt; isSpecificTypeIssuer(String issuerType, String targetIssuerWeId)
接口描述: 判断issuer是否为指定机构里面的成员。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>issuerType</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构类型</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>targetIssuerWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer的WeIdentity DID</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否为指定类型中的成员</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-odd"><td><p>SPECIFIC_ISSUER_TYPE_ILLEGAL</p></td>
<td><p>100208</p></td>
<td><p>机构类型非法</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>SPECIFIC_ISSUER_CONTRACT_ERROR_ALREADY_NOT_EXIST</p></td>
<td><p>500502</p></td>
<td><p>授权人不存在</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">AuthorityIssuerService</span> <span class="n">authorityIssuerService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AuthorityIssuerServiceImpl</span><span class="o">();</span>
<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">;</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">authorityIssuerService</span><span class="o">.</span><span class="na">isAuthorityIssuer</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant AuthorityIssuerService
participant 区块链节点
调用者-&gt;&gt;AuthorityIssuerService: 调用IsAuthorityIssuer()
AuthorityIssuerService-&gt;&gt;AuthorityIssuerService: 入参非空、格式及合法性检查
opt 入参校验失败
AuthorityIssuerService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
AuthorityIssuerService-&gt;&gt;区块链节点: 调用查询是否为授权机构合约
区块链节点-&gt;&gt;区块链节点: 执行合约通过WeIdentity DID查询
区块链节点--&gt;&gt;AuthorityIssuerService: 返回查询结果
AuthorityIssuerService--&gt;&gt;调用者: 返回是/否
        </div></div>
<hr class="docutils" />
<div class="section" id="getallspecifictypeissuerlist">
<h4>10. getAllSpecificTypeIssuerList<a class="headerlink" href="#getallspecifictypeissuerlist" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AuthorityIssuerService.getAllSpecificTypeIssuerList
接口定义: ResponseData&lt;List&lt;String&gt;&gt; getAllSpecificTypeIssuerList(String issuerType, Integer index, Integer num)
接口描述: 获取指定索引范围内的issuer列表。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>issuerType</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构类型</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>index</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>检索的开始下标位置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>num</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>检索数据个数</p></td>
<td><p>单次最多可以检索50条</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;List&lt;String&gt;&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>issuer列表</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>AUTHORITY_ISSUER_ERROR</p></td>
<td><p>100200</p></td>
<td><p>授权标准异常</p></td>
</tr>
<tr class="row-even"><td><p>SPECIFIC_ISSUER_TYPE_ILLEGAL</p></td>
<td><p>100208</p></td>
<td><p>机构类型非法</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如：
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="cptservice">
<h3>CptService<a class="headerlink" href="#cptservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="registercpt">
<h4>1. registerCpt<a class="headerlink" href="#registercpt" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CptService.registerCpt
接口定义:ResponseData&lt;CptBaseInfo&gt; registerCpt(CptMapArgs args)
接口描述: 传入WeIdentity DID，JsonSchema(Map类型) 和其对应的私钥，链上注册CPT，返回CPT编号和版本。
</pre></div>
</div>
<p><strong>接口入参</strong>:    com.webank.weid.protocol.request.CptMapArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Map类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-even"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchema</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TITLE_KEY</span><span class="o">,</span> <span class="s">&quot;cpt template&quot;</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is a cpt template&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is name&quot;</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderEnum</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;F&quot;</span><span class="o">,</span> <span class="s">&quot;M&quot;</span> <span class="o">};</span>
<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_ENUM</span><span class="o">,</span> <span class="n">genderEnum</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_NUMBER</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is age&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchemaKeys</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="n">propertitesMap1</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="n">propertitesMap2</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="n">propertitesMap3</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">PROPERTIES_KEY</span><span class="o">,</span> <span class="n">cptJsonSchemaKeys</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderRequired</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;gender&quot;</span> <span class="o">};</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">REQUIRED_KEY</span><span class="o">,</span> <span class="n">genderRequired</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptMapArgs</span> <span class="n">cptMapArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptMapArgs</span><span class="o">();</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">cptJsonSchema</span><span class="o">);</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">registerCpt</span><span class="o">(</span><span class="n">cptMapArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 1016
   cptVersion: 1
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29950
       transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
       transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>
<p>（同时也包含重载updateCpt时序）</p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
调用者-&gt;&gt;WeIdentity SDK : 传入自己已有的WeIdentity DID及对应的私钥，及其jsonSchema，调用registerCpt来注册CPT。
opt 参数校验
Note over WeIdentity SDK:如果WeIdentity DID或者私钥为空或不匹配
WeIdentity SDK-&gt;&gt;WeIdentity SDK:报错，提示参数不合法并退出
end
WeIdentity SDK-&gt;&gt;区块链节点: 将java对象转换为合约所需的字段，调用智能合约，将CPT信息上链
opt 身份校验
Note over 区块链节点:如果传入WeIdentity DID在链上不存在
区块链节点-&gt;&gt;区块链节点:报错，提示WeIdentity DID不存在并退出
end
区块链节点-&gt;&gt;区块链节点:写入CPT信息
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="id19">
<h4>2. registerCpt<a class="headerlink" href="#id19" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.CptService.registerCpt
接口定义: ResponseData&lt;CptBaseInfo&gt; registerCpt(CptMapArgs args, Integer cptId)
接口描述: 传入WeIdentity DID，JsonSchema(Map类型), cptId 和其对应的私钥，链上注册指定cptId的CPT，返回CPT编号和版本。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>args</p></td>
<td><p>CptMapArgs</p></td>
<td><p>Y</p></td>
<td><p>Map类型参数注册CPT</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>指定的cptId</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.request.CptMapArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Map类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ALREADY_EXIST</p></td>
<td><p>500304</p></td>
<td><p>CPT已经存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NO_PERMISSION</p></td>
<td><p>500305</p></td>
<td><p>CPT无权限</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchema</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TITLE_KEY</span><span class="o">,</span> <span class="s">&quot;cpt template&quot;</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is a cpt template&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is name&quot;</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderEnum</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;F&quot;</span><span class="o">,</span> <span class="s">&quot;M&quot;</span> <span class="o">};</span>
<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_ENUM</span><span class="o">,</span> <span class="n">genderEnum</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_NUMBER</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is age&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap4</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap4</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is id&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchemaKeys</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="n">propertitesMap1</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="n">propertitesMap2</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="n">propertitesMap3</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;id&quot;</span><span class="o">,</span> <span class="n">propertitesMap4</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">PROPERTIES_KEY</span><span class="o">,</span> <span class="n">cptJsonSchemaKeys</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderRequired</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;id&quot;</span><span class="o">,</span> <span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;gender&quot;</span> <span class="o">};</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">REQUIRED_KEY</span><span class="o">,</span> <span class="n">genderRequired</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptMapArgs</span> <span class="n">cptMapArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptMapArgs</span><span class="o">();</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">cptJsonSchema</span><span class="o">);</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">registerCpt</span><span class="o">(</span><span class="n">cptMapArgs</span><span class="o">,</span> <span class="mi">101</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 101
   cptVersion: 1
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
       blockNumber: 29950
       transactionHash: 0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13
       transactionIndex: 0
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id20">
<h4>3. registerCpt<a class="headerlink" href="#id20" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CptService.registerCpt
接口定义:ResponseData&lt;CptBaseInfo&gt; registerCpt(CptStringArgs args)
接口描述: 传入WeIdentity DID，JsonSchema(String类型) 和其对应的私钥，链上注册CPT，返回CPT编号和版本。
</pre></div>
</div>
<p><strong>接口入参</strong>:    com.webank.weid.protocol.request.CptStringArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>字符串类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ALREADY_EXIST</p></td>
<td><p>500304</p></td>
<td><p>CPT已经存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NO_PERMISSION</p></td>
<td><p>500305</p></td>
<td><p>CPT无权限</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">String</span> <span class="n">jsonSchema</span> <span class="o">=</span> <span class="s">&quot;{\&quot;properties\&quot; : {\&quot;name\&quot;: {\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the name of certificate owner\&quot;},\&quot;gender\&quot;: {\&quot;enum\&quot;: [\&quot;F\&quot;, \&quot;M\&quot;],\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the gender of certificate owner\&quot;}, \&quot;age\&quot;: {\&quot;type\&quot;: \&quot;number\&quot;, \&quot;description\&quot;: \&quot;the age of certificate owner\&quot;}},\&quot;required\&quot;: [\&quot;name\&quot;, \&quot;age\&quot;]}&quot;</span><span class="o">;</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptStringArgs</span> <span class="n">cptStringArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptStringArgs</span><span class="o">();</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">jsonSchema</span><span class="o">);</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">registerCpt</span><span class="o">(</span><span class="n">cptStringArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 1017
   cptVersion: 1
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 29964
   transactionHash: 0xf3b039557b2d1e575e9949b3a33d34ee5c8749b55940347d18a0f7e929eda799
   transactionIndex: 0
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id21">
<h4>4. registerCpt<a class="headerlink" href="#id21" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.CptService.registerCpt
接口定义: ResponseData&lt;CptBaseInfo&gt; registerCpt(CptStringArgs args, Integer cptId)
接口描述: 传入WeIdentity DID，JsonSchema(String类型) , cptId和其对应的私钥，链上注册指定cptId的CPT，返回CPT编号和版本。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>args</p></td>
<td><p>CptStringArgs</p></td>
<td><p>Y</p></td>
<td><p>String类型参数注册CPT</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>指定的cptId</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.request.CptStringArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>字符串类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ALREADY_EXIST</p></td>
<td><p>500304</p></td>
<td><p>CPT已经存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NO_PERMISSION</p></td>
<td><p>500305</p></td>
<td><p>CPT无权限</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">String</span> <span class="n">jsonSchema</span> <span class="o">=</span> <span class="s">&quot;{\&quot;properties\&quot; : {\&quot;id\&quot;: {\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the id of certificate owner\&quot;}, \&quot;name\&quot;: {\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the name of certificate owner\&quot;},\&quot;gender\&quot;: {\&quot;enum\&quot;: [\&quot;F\&quot;, \&quot;M\&quot;],\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the gender of certificate owner\&quot;}, \&quot;age\&quot;: {\&quot;type\&quot;: \&quot;number\&quot;, \&quot;description\&quot;: \&quot;the age of certificate owner\&quot;}},\&quot;required\&quot;: [\&quot;id\&quot;, \&quot;name\&quot;, \&quot;age\&quot;]}&quot;</span><span class="o">;</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptStringArgs</span> <span class="n">cptStringArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptStringArgs</span><span class="o">();</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">jsonSchema</span><span class="o">);</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">registerCpt</span><span class="o">(</span><span class="n">cptStringArgs</span><span class="o">,</span> <span class="mi">103</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 103
   cptVersion: 1
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 29910
   transactionHash: 0xf3b039557b2d1e575e9949b3a33d34e35c8749b55940347d18a0f7e929eda799
   transactionIndex: 0
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="querycpt">
<h4>5. queryCpt<a class="headerlink" href="#querycpt" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CptService.queryCpt
接口定义:ResponseData&lt;Cpt&gt; queryCpt(Integer cptId)
接口描述: 根据CPT编号查询CPT信息。
</pre></div>
</div>
<p><strong>接口入参</strong>:    java.lang.Integer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId编号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Cpt&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Cpt</p></td>
<td></td>
<td><p>CPT内容，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Cpt</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptJsonSchema</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Map类型的cptJsonSchema信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptBaseInfo</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-even"><td><p>cptMetaData</p></td>
<td><p>CptMetaData</p></td>
<td></td>
<td><p>CPT元数据内部类，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Cpt.MetaData</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptPublisher</p></td>
<td><p>String</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID格式数据</p></td>
</tr>
<tr class="row-odd"><td><p>cptSignature</p></td>
<td><p>String</p></td>
<td><p>签名数据</p></td>
<td><p>cptPublisher与cptJsonSchema拼接的签名数据</p></td>
</tr>
<tr class="row-even"><td><p>updated</p></td>
<td><p>long</p></td>
<td><p>更新时间</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>created</p></td>
<td><p>long</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>
<span class="n">Integer</span> <span class="n">cptId</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Cpt</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">queryCpt</span><span class="o">(</span><span class="n">cptId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.Cpt)
   cptBaseInfo:(com.webank.weid.protocol.base.CptBaseInfo)
      cptId: 1017
      cptVersion: 1
   cptJsonSchema:(java.util.HashMap)
      $schema: http://json-schema.org/draft-04/schema#
      type: object
      properties:(java.util.LinkedHashMap)
         age:(java.util.LinkedHashMap)
            description: the age of certificate owner
            type: number
         gender:(java.util.LinkedHashMap)
            description: the gender of certificate owner
            enum:(java.util.ArrayList)
               [0]:F
               [1]:M
            type: string
         name:(java.util.LinkedHashMap)
            description: the name of certificate owner
            type: string
      required:(java.util.ArrayList)
         [0]:name
         [1]:age
   metaData:(com.webank.weid.protocol.base.Cpt$MetaData)
      cptPublisher: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
      cptSignature: G/YGY8Ftj9jPRdtr4ym+19M4/K6x9RbmRiV9JkryXeQGFr8eukDCBAcbinnNpF2N3Eo72bvxNqJOKx4ohWIus0Y=
      created: 1560415607673
      updated: 0
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
调用者-&gt;&gt;WeIdentity SDK : 传入指定的cptId
opt 参数校验
Note over WeIdentity SDK:检查传入的cptId是否为空或负数
WeIdentity SDK-&gt;&gt;WeIdentity SDK:报错，提示weid不合法并退出
end
WeIdentity SDK-&gt;&gt;区块链节点: 调用合约查询链上的指定cpt对应的信息
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK-&gt;&gt;WeIdentity SDK:根据合约返回的值构建返回的java对象
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="updatecpt">
<h4>6. updateCpt<a class="headerlink" href="#updatecpt" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CptService.updateCpt
接口定义:ResponseData&lt;CptBaseInfo&gt; updateCpt(CptMapArgs args, Integer cptId)
接口描述: 传入cptId，JsonSchema(Map类型)，WeIdentity DID，WeIdentity DID所属私钥，进行更新CPT信息，更新成功版本自动+1。
</pre></div>
</div>
<p><strong>接口入参</strong>:    com.webank.weid.protocol.request.CptMapArgs，Integer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>args</p></td>
<td><p>CptMapArgs</p></td>
<td><p>Y</p></td>
<td><p>CPT信息</p></td>
<td><p>具体见下</p></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>发布的CPT编号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.request.CptMapArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Map类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-even"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-even"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ALREADY_EXIST</p></td>
<td><p>500304</p></td>
<td><p>CPT已经存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_NO_PERMISSION</p></td>
<td><p>500305</p></td>
<td><p>CPT无权限</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchema</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TITLE_KEY</span><span class="o">,</span> <span class="s">&quot;cpt template&quot;</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is a cpt template&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is name&quot;</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderEnum</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;F&quot;</span><span class="o">,</span> <span class="s">&quot;M&quot;</span> <span class="o">};</span>
<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_STRING</span><span class="o">);</span>
<span class="n">propertitesMap2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_ENUM</span><span class="o">,</span> <span class="n">genderEnum</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">propertitesMap3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">2</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">TYPE_KEY</span><span class="o">,</span> <span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DATA_TYPE_NUMBER</span><span class="o">);</span>
<span class="n">propertitesMap3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">DESCRIPTION_KEY</span><span class="o">,</span> <span class="s">&quot;this is age&quot;</span><span class="o">);</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">cptJsonSchemaKeys</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="n">propertitesMap1</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="n">propertitesMap2</span><span class="o">);</span>
<span class="n">cptJsonSchemaKeys</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="n">propertitesMap3</span><span class="o">);</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">PROPERTIES_KEY</span><span class="o">,</span> <span class="n">cptJsonSchemaKeys</span><span class="o">);</span>

<span class="n">String</span><span class="o">[]</span> <span class="n">genderRequired</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;gender&quot;</span> <span class="o">};</span>
<span class="n">cptJsonSchema</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">JsonSchemaConstant</span><span class="o">.</span><span class="na">REQUIRED_KEY</span><span class="o">,</span> <span class="n">genderRequired</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptMapArgs</span> <span class="n">cptMapArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptMapArgs</span><span class="o">();</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">cptJsonSchema</span><span class="o">);</span>
<span class="n">cptMapArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Integer</span> <span class="n">cptId</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">updateCpt</span><span class="o">(</span><span class="n">cptMapArgs</span><span class="o">,</span> <span class="n">cptId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 1017
   cptVersion: 2
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 29989
   transactionHash: 0x4435fa88f9f138f14671d8baa5e5f16c69c5efa3591c4912772b9b1233af398a
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>
<p>（同时也包含重载updateCpt时序）</p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
调用者-&gt;&gt;WeIdentity SDK : 传入自己已有的WeIdentity DID及对应的私钥，及其需新版本的jsonSchema，调用updateCpt来更新CPT。
opt 参数校验
Note over WeIdentity SDK:如果WeIdentity DID或者私钥为空或不匹配
WeIdentity SDK-&gt;&gt;WeIdentity SDK:报错，提示参数不合法并退出
end
WeIdentity SDK-&gt;&gt;区块链节点: 将java对象转换为合约所需的字段，调用智能合约，将更新的CPT信息上链
opt 身份校验
Note over 区块链节点:如果传入WeIdentity DID在链上不存在
区块链节点-&gt;&gt;区块链节点:报错，提示WeIdentity DID不存在并退出
end
区块链节点-&gt;&gt;区块链节点:写入CPT更新信息
区块链节点--&gt;&gt;WeIdentity SDK:返回
WeIdentity SDK--&gt;&gt;调用者:返回调用结果
        </div></div>
<hr class="docutils" />
<div class="section" id="id22">
<h4>7. updateCpt<a class="headerlink" href="#id22" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CptService.updateCpt
接口定义:ResponseData&lt;CptBaseInfo&gt; updateCpt(CptStringArgs args, Integer cptId)
接口描述: 传入cptId，JsonSchema(String类型)，WeIdentity DID，WeIdentity DID所属私钥，进行更新CPT信息，更新成功版本自动+1。
</pre></div>
</div>
<p><strong>接口入参</strong>:    com.webank.weid.protocol.request.CptStringArgs，Integer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>args</p></td>
<td><p>CptStringArgs</p></td>
<td><p>Y</p></td>
<td><p>CPT信息</p></td>
<td><p>具体见下</p></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>发布的CPT编号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.request.CptStringArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>认证信息，包含WeIdentity DID和私钥</p></td>
<td><p>用于WeIdentity DID的身份认证</p></td>
</tr>
<tr class="row-odd"><td><p>cptJsonSchema</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>字符串类型的JsonSchema信息</p></td>
<td><p>基本使用见调用示例</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CptBaseInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td><p>此接口返回的code</p></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CptBaseInfo</p></td>
<td></td>
<td><p>CPT基础数据，见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CptBaseInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cpId编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptVersion</p></td>
<td><p>Integer</p></td>
<td><p>版本号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_INVALID</p></td>
<td><p>100101</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_INVALID</p></td>
<td><p>100103</p></td>
<td><p>私钥无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>schema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_EVENT_LOG_NULL</p></td>
<td><p>100304</p></td>
<td><p>交易日志异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-even"><td><p>CPT_NOT_EXISTS</p></td>
<td><p>500301</p></td>
<td><p>CPT不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_AUTHORITY_ISSUER_EXCEED_MAX</p></td>
<td><p>500302</p></td>
<td><p>为权威机构生成的cptId超过上限</p></td>
</tr>
<tr class="row-even"><td><p>CPT_PUBLISHER_NOT_EXIST</p></td>
<td><p>500303</p></td>
<td><p>CPT发布者的WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ALREADY_EXIST</p></td>
<td><p>500304</p></td>
<td><p>CPT已经存在</p></td>
</tr>
<tr class="row-even"><td><p>CPT_NO_PERMISSION</p></td>
<td><p>500305</p></td>
<td><p>CPT无权限</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CptService</span> <span class="n">cptService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptServiceImpl</span><span class="o">();</span>

<span class="n">String</span> <span class="n">jsonSchema</span> <span class="o">=</span> <span class="s">&quot;{\&quot;properties\&quot; : {\&quot;name\&quot;: {\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the name of certificate owner\&quot;},\&quot;gender\&quot;: {\&quot;enum\&quot;: [\&quot;F\&quot;, \&quot;M\&quot;],\&quot;type\&quot;: \&quot;string\&quot;,\&quot;description\&quot;: \&quot;the gender of certificate owner\&quot;}, \&quot;age\&quot;: {\&quot;type\&quot;: \&quot;number\&quot;, \&quot;description\&quot;: \&quot;the age of certificate owner\&quot;}},\&quot;required\&quot;: [\&quot;name\&quot;, \&quot;age\&quot;]}&quot;</span><span class="o">;</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">CptStringArgs</span> <span class="n">cptStringArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CptStringArgs</span><span class="o">();</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setCptJsonSchema</span><span class="o">(</span><span class="n">jsonSchema</span><span class="o">);</span>
<span class="n">cptStringArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Integer</span> <span class="n">cptId</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CptBaseInfo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cptService</span><span class="o">.</span><span class="na">updateCpt</span><span class="o">(</span><span class="n">cptStringArgs</span><span class="o">,</span> <span class="n">cptId</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回数据如下：
result:(com.webank.weid.protocol.base.CptBaseInfo)
   cptId: 1017
   cptVersion: 3
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 29991
   transactionHash: 0x8ed8113dd1772ae74e6f12de3d3716d76a410190c3d564d5d5842b85c7005aee
   transactionIndex: 0
</pre></div>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="credentialservice">
<h3>CredentialService<a class="headerlink" href="#credentialservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="createcredential">
<h4>1. createCredential<a class="headerlink" href="#createcredential" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.createCredential
接口定义:ResponseData&lt;CredentialWrapper&gt; createCredential(CreateCredentialArgs args)
接口描述: 创建电子凭证。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.request.CreateCredentialArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>CPT编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>发行方WeIdentity DID</p></td>
<td><p>WeIdentity DID格式数据</p></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Map类型的claim数据</p></td>
<td><p>凭证所需数据</p></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>签名所用Issuer WeIdentity DID私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CredentialWrapper&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CredentialWrapper</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialWrapper</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>credential</p></td>
<td><p>Credential</p></td>
<td><p>Y</p></td>
<td><p>凭证信息</p></td>
<td><p>具体见下</p></td>
</tr>
<tr class="row-odd"><td><p>disclosure</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>披露属性</p></td>
<td><p>默认为全披露</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>JsonSchema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1551448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialWrapper)
   credential:(com.webank.weid.protocol.base.Credential)
      context: https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1
      id: f931b882-00ab-4cb0-9e83-d9bb57212e81
      cptId: 1017
      issuer: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
      issuanceDate: 1560416978296
      expirationDate: 1551448312461
      claim:(java.util.HashMap)
         name: zhang san
         gender: F
         age: 18
      proof:(java.util.HashMap)
         creator: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
         signature: HHQwJ9eEpyv/BgwtWDveFYAPsKOPtEEWt6ieb28PS76pDwlpFKtbh9Ygog8SUPIXUaWNYS2pLkk4E91hpP8IdbU=
         created: 1560416978296
         type: Secp256k1
   disclosure:(java.util.HashMap)
      name: 1
      gender: 1
      age: 1
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialService
调用者-&gt;&gt;CredentialService: 调用CreateCredential()
CredentialService-&gt;&gt;CredentialService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialService-&gt;&gt;CredentialService: 生成签发日期、生成数字签名
CredentialService--&gt;&gt;调用者: 返回凭证
        </div></div>
<hr class="docutils" />
<div class="section" id="verify">
<h4>2. verify<a class="headerlink" href="#verify" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.verify
接口定义:ResponseData&lt;Boolean&gt; verify(Credential credential);
接口描述: 验证凭证是否正确。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuer与签名不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_NOT_EXISTS</p></td>
<td><p>100407</p></td>
<td><p>WeIdentity DID不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CPT_NOT_EXISTS</p></td>
<td><p>100416</p></td>
<td><p>cpt不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td><p>WeIdentity Document为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>验证签名异常</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">//创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="c1">//验证Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">responseVerify</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">verify</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>
<p>（同时也包含verifyCredentialWithSpecifiedPubKey时序）</p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialService
participant CptService
participant WeIdService
participant 区块链节点
调用者-&gt;&gt;CredentialService: 调用verify()或verifyCredentialWithSpecifiedPubKey()
CredentialService-&gt;&gt;CredentialService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialService-&gt;&gt;WeIdService: 查询WeIdentity DID存在性
WeIdService-&gt;&gt;区块链节点: 调用智能合约，查询WeIdentity DID属性
区块链节点--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;CredentialService: 返回查询结果
opt 查询不存在
CredentialService--&gt;&gt;调用者: 报错并退出
end
CredentialService-&gt;&gt;CptService: 查询CPT存在性及Claim关联语义
CptService-&gt;&gt;区块链节点: 调用智能合约，查询CPT
区块链节点--&gt;&gt;CptService: 返回查询结果
CptService--&gt;&gt;CredentialService: 返回查询结果
opt 不符合CPT格式要求
CredentialService--&gt;&gt;调用者: 报错并退出
end
CredentialService-&gt;&gt;CredentialService: 验证过期、撤销与否
opt 任一验证失败
CredentialService--&gt;&gt;调用者: 报错并退出
end
opt 未提供验签公钥
CredentialService-&gt;&gt;WeIdService: 查询Issuer对应公钥
WeIdService-&gt;&gt;区块链节点: 调用智能合约，查询Issuer的WeIdentity DID Document
区块链节点--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;CredentialService: 返回查询结果
end
CredentialService-&gt;&gt;CredentialService: 通过公钥与签名对比，验证Issuer是否签发此凭证
opt 验证签名失败
CredentialService--&gt;&gt;调用者: 报错并退出
end
CredentialService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="verifycredentialwithspecifiedpubkey">
<h4>3. verifyCredentialWithSpecifiedPubKey<a class="headerlink" href="#verifycredentialwithspecifiedpubkey" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.verifyCredentialWithSpecifiedPubKey
接口定义: ResponseData&lt;Boolean&gt; verifyCredentialWithSpecifiedPubKey(CredentialWrapper credentialWrapper, WeIdPublicKey weIdPublicKey)
接口描述: 验证凭证是否正确，需传入公钥。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>credentialWrapper</p></td>
<td><p>CredentialWrapper</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>凭证信息，见下</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKey</p></td>
<td><p>WeIdPublicKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>公钥信息，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialWrapper</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>credential</p></td>
<td><p>Credential</p></td>
<td><p>Y</p></td>
<td><p>凭证信息</p></td>
<td><p>具体见下</p></td>
</tr>
<tr class="row-odd"><td><p>disclosure</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>N</p></td>
<td><p>披露属性</p></td>
<td><p>默认为全披露</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPublicKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>数字公钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuer与签名不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_NOT_EXISTS</p></td>
<td><p>100407</p></td>
<td><p>WeIdentity DID不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CPT_NOT_EXISTS</p></td>
<td><p>100416</p></td>
<td><p>cpt不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td><p>WeIdentity Document为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>验证签名异常</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">// 创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="n">WeIdPublicKey</span> <span class="n">weIdPublicKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPublicKey</span><span class="o">();</span>
<span class="n">weIdPublicKey</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span>
   <span class="s">&quot;9202079291855274840499629257327649367489192973501473466426182121217769706994308329953406897395674428921435762028726727399019951049448689033610431403383875&quot;</span><span class="o">);</span>

<span class="c1">//使用公钥验证</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">responseVerify</span> <span class="o">=</span> <span class="n">credentialService</span>
   <span class="o">.</span><span class="na">verifyCredentialWithSpecifiedPubKey</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">(),</span> <span class="n">weIdPublicKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="getcredentialhash">
<h4>4. getCredentialHash<a class="headerlink" href="#getcredentialhash" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.getCredentialHash
接口定义:ResponseData&lt;String&gt; getCredentialHash(Credential args)
接口描述: 传入Credential信息生成Credential整体的Hash值，一般在生成Evidence时调用。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

     <span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>
<span class="c1">//创建Credentia</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="c1">//获取Credentia的Hash</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseHash</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">getCredentialHash</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0x06173e4b714d57565ae5ddf23c4e84cb0a9824cb72eab476303d2dd1cc0a4728
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialService
调用者-&gt;&gt;CredentialService: 调用GetCredentialHash()
CredentialService-&gt;&gt;CredentialService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialService-&gt;&gt;CredentialService: 生成凭证Hash
CredentialService--&gt;&gt;调用者: 返回凭证Hash
        </div></div>
<hr class="docutils" />
<div class="section" id="id23">
<h4>5. getCredentialHash<a class="headerlink" href="#id23" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.getCredentialHash
接口定义:ResponseData&lt;String&gt; getCredentialHash(CredentialWrapper args)
接口描述: 传入Credential信息生成Credential整体的Hash值，一般在生成Evidence时调用。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.base.CredentialWrapper</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>credential</p></td>
<td><p>Credential</p></td>
<td><p>Y</p></td>
<td><p>凭证信息</p></td>
<td><p>具体见下</p></td>
</tr>
<tr class="row-odd"><td><p>disclosure</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>披露属性</p></td>
<td><p>默认为全披露</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

      <span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>
<span class="c1">//创建CredentialWrapper</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="c1">//获取CredentialWrapper的Hash</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseHash</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">getCredentialHash</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0x06173e4b714d57565ae5ddf23c4e84cb0a9824cb72eab476303d2dd1cc0a4728
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialService
调用者-&gt;&gt;CredentialService: 调用GetCredentialHash()
CredentialService-&gt;&gt;CredentialService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialService-&gt;&gt;CredentialService: 生成凭证Hash
CredentialService--&gt;&gt;调用者: 返回凭证Hash
        </div></div>
<div class="section" id="addsignature">
<h4>6. addSignature<a class="headerlink" href="#addsignature" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialService.addSignature
接口定义:ResponseData&lt;Credential&gt; addSignature(List&lt;Credential&gt; credentialList, WeIdPrivateKey weIdPrivateKey)
接口描述:多签，在原凭证列表的基础上，创建包裹成一个新的多签凭证，由传入的私钥所签名。此凭证的CPT为一个固定值。在验证一个多签凭证时，会迭代验证其包裹的所有子凭证。本接口不支持创建选择性披露的多签凭证。
</pre></div>
</div>
<p><strong>接口入参</strong>:   java.util.ArrayList</p>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Credential&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Credential</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td><p>默认为106</p></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>JsonSchema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1551448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">Credential</span><span class="o">&gt;</span> <span class="n">credList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">credList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">());</span>
   <span class="n">Long</span> <span class="n">expirationDate</span> <span class="o">=</span> <span class="n">DateUtils</span><span class="o">.</span><span class="na">convertToNoMillisecondTimeStamp</span><span class="o">(</span>
    <span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">getExpirationDate</span><span class="o">()</span> <span class="o">+</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">expirationDate</span><span class="o">);</span>
<span class="n">Credential</span> <span class="n">tempCredential</span> <span class="o">=</span>
    <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">).</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">tempCredential</span><span class="o">);</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Credential</span><span class="o">&gt;</span> <span class="n">multiSignedResp</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">addSignature</span><span class="o">(</span><span class="n">credList</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">multiSignedResp</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialWrapper)
   credential:(com.webank.weid.protocol.base.Credential) {
     &quot;claim&quot;: {
       &quot;credentialList&quot;: [
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 18,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:101:0xe4bee5a07f282ffd3109699e21663cde0210fb64&quot;,
             &quot;name&quot;: &quot;zhang san&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000084,
           &quot;expirationDate&quot;: 1567488114,
           &quot;id&quot;: &quot;a8b1c030-231d-49de-9618-b5ed7f3e6d2e&quot;,
           &quot;issuanceDate&quot;: 1567401714,
           &quot;issuer&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: &quot;1567401714&quot;,
             &quot;creator&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
             &quot;signature&quot;: &quot;GwKcDoEseYdJxI7M\/R4RAdGcV5SJoFVvg8Z53BVa76LMV8eqbX3F4rb1dWjhqI286AvPECx6uuuo9cTAKuNHRXM=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           }
         },
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 18,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:101:0xe4bee5a07f282ffd3109699e21663cde0210fb64&quot;,
             &quot;name&quot;: &quot;zhang san&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000084,
           &quot;expirationDate&quot;: 1567488201,
           &quot;id&quot;: &quot;2130908d-fb2a-4675-8bf1-727f354ca8e4&quot;,
           &quot;issuanceDate&quot;: 1567401715,
           &quot;issuer&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: &quot;1567401715&quot;,
             &quot;creator&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
             &quot;signature&quot;: &quot;HJXDuvg2l8jRbL5ymmBSAo\/6DMKbCv3P1XoP67S+OVzSbRVDNFXY1CsqpTqT5MAkSY4+UwPLwCfXrLtHsZQ6GOo=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           }
         }
       ]
     },
     &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
     &quot;cptId&quot;: 106,
     &quot;expirationDate&quot;: 1567488201,
     &quot;id&quot;: &quot;d8642623-703f-447a-8765-dab1dab4df0a&quot;,
     &quot;issuanceDate&quot;: 1567401717,
     &quot;issuer&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
     &quot;proof&quot;: {
       &quot;created&quot;: &quot;1567401717&quot;,
       &quot;creator&quot;: &quot;did:weid:1:0x92d5472954c38375371f8bdd2bcce2e64aab1f99&quot;,
       &quot;signature&quot;: &quot;HKXEwzDEwqte4aAUBLvQjiI3C0cw5V\/iWeKWmBs7HIG0IRzgbXnMj8kYw37y5yJE4KdsWCuehBUGuW7WdihL560=&quot;,
       &quot;type&quot;: &quot;Secp256k1&quot;
     }
   }
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialService
调用者-&gt;&gt;CredentialService: 调用addSignature()
CredentialService-&gt;&gt;CredentialService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialService-&gt;&gt;CredentialService: 生成签发日期、以原凭证列表为Claim生成数字签名
CredentialService--&gt;&gt;调用者: 返回凭证
        </div></div>
</div>
<hr class="docutils" />
<div class="section" id="evidenceservice">
<h3>EvidenceService<a class="headerlink" href="#evidenceservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="createevidence">
<h4>1. createEvidence<a class="headerlink" href="#createevidence" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.createEvidence
接口定义:ResponseData&lt;String&gt; createEvidence(Hashable object, WeIdPrivateKey weIdPrivateKey)
接口描述: 将传入Object计算Hash值生成存证上链，返回存证地址。传入的私钥将会成为链上存证的签名方。此签名方和凭证的Issuer可以不是同一方。当传入的object为null时，则会创建一个空的存证并返回其地址，空存证中仅包含签名方，不含Hash值。可以随后调用SetHashValue()方法，为空存证添加Hash值和签名。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>Hashable java.lang.Object</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Object</p></td>
<td><p>Hashable object</p></td>
<td><p>N</p></td>
<td><p>实现了Hashable接口的任意Object</p></td>
<td><p>当前支持Credential，CredentialWrapper，CredentialPojo</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>创建的凭证合约地址</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_CONTRACT_FAILURE_ILLEAGAL_INPUT</p></td>
<td><p>500401</p></td>
<td><p>Evidence参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>
<span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">// 创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="c1">//创建Evidence Address</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseCreateEvidence</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">(),</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0xa3203e054bb7a7f0dec134c7510299869e343e8d
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30014
   transactionHash: 0x1f9e62fa152eb5fce859dcf81c7c0eddcbcab63c40629d1c745058c227693dae
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用CreateEvidence()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;EvidenceService: 生成凭证Hash
EvidenceService-&gt;&gt;EvidenceService: 基于凭证Hash生成签名值
EvidenceService-&gt;&gt;区块链节点: 调用智能合约，创建并上传凭证存证
区块链节点--&gt;&gt;EvidenceService: 返回创建结果
opt 创建失败
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id24">
<h4>2. createEvidence （多个签名方）<a class="headerlink" href="#id24" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.createEvidence
接口定义:ResponseData&lt;String&gt; createEvidence(Hashable object, List&lt;String&gt; signers, WeIdPrivateKey weIdPrivateKey)
接口描述: 将传入Object计算Hash值生成存证上链。此方法允许在创建存证时传入多个签名方的WeID；但是，必须传入一个这些签名方WeID所对应持有的私钥进行签名。同样地，此签名方和凭证的Issuer可以不是同一方。当传入的object为null时，则会创建一个空的存证并返回其地址，空存证中仅包含签名方，不含Hash值。可以随后调用SetHashValue()方法，为空存证添加Hash值和签名。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>Hashable java.lang.Object</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Object</p></td>
<td><p>Hashable object</p></td>
<td><p>N</p></td>
<td><p>实现了Hashable接口的任意Object</p></td>
<td><p>当前支持Credential，CredentialWrapper，CredentialPojo</p></td>
</tr>
</tbody>
</table>
<p>java.util.ArrayList</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>signers</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td><p>声明的签名者的WeID</p></td>
<td><p>至少有一个签名者需要传入自己的私钥（在下个参数中）</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>创建的凭证合约地址</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_CONTRACT_FAILURE_ILLEAGAL_INPUT</p></td>
<td><p>500401</p></td>
<td><p>Evidence参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>
<span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">// 创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">signer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x48f6f6f663ef77409144014ceb063713b65611f8&quot;</span><span class="o">);</span>

<span class="c1">//创建Evidence Address</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseCreateEvidence</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">(),</span> <span class="n">signer</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0xa3203e054bb7a7f0dec134c7510299869e343e8d
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30014
   transactionHash: 0x1f9e62fa152eb5fce859dcf81c7c0eddcbcab63c40629d1c745058c227693dae
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用CreateEvidence()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;EvidenceService: 生成凭证Hash
EvidenceService-&gt;&gt;EvidenceService: 基于凭证Hash生成签名值
EvidenceService-&gt;&gt;区块链节点: 调用智能合约，创建并上传凭证存证
区块链节点--&gt;&gt;EvidenceService: 返回创建结果
opt 创建失败
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="getevidence">
<h4>3. getEvidence<a class="headerlink" href="#getevidence" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.getEvidence
接口定义:ResponseData&lt;EvidenceInfo&gt; getEvidence(String evidenceAddress)
接口描述: 根据传入的凭证存证地址，在链上查找凭证存证信息。
</pre></div>
</div>
<p><strong>接口入参</strong>:   String</p>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;EvidenceInfo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>EvidenceInfo</p></td>
<td><p>创建的凭证合约地址</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.EvidenceInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>credentialHash</p></td>
<td><p>String</p></td>
<td><p>凭证Hash值</p></td>
<td><p>是一个66个字节的字符串，以0x开头</p></td>
</tr>
<tr class="row-odd"><td><p>signers</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>凭证签发者</p></td>
<td><p>链上允许存在多个凭证签发者</p></td>
</tr>
<tr class="row-even"><td><p>signatures</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>签发者生成签名</p></td>
<td><p>和每个签发者一一按序对应的签名值</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Evidence</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">getEvidence</span><span class="o">(</span><span class="s">&quot;0xa3203e054bb7a7f0dec134c7510299869e343e8d&quot;</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.EvidenceInfo)
   credentialHash: 0x31c2db44db19ec1af69ed6ad2dc36c7a8068c9871cf1a2bd0e67cb6264531f35
   signers:(java.util.ArrayList)
      [0]:0x39e5e6f663ef77409144014ceb063713b65600e7
   signatures:(java.util.ArrayList)
      [0]:HJoVLhynrqekQWjMEHubd0e5E/J3LLfnWtq3CXpjFaA/Tfj3i0+dDGfa76OqoZhqSuNucXW8f4BZn/Lkd6SPQ/I=
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用GetEvidence()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;区块链节点: 调用智能合约，查询凭证存证内容
区块链节点--&gt;&gt;EvidenceService: 返回查询结果
opt 查询出错
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id25">
<h4>4. addSignature<a class="headerlink" href="#id25" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.addSignature
接口定义:ResponseData&lt;String&gt; addSignature(Hashable object, String evidenceAddress, WeIdPrivateKey weIdPrivateKey)
接口描述: 对传入的Object及链上地址，加一个签名存入链上的存证。要求：传入的签名方必须隶属于在创建存证时传入多个签名方的WeID之一。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>Hashable java.lang.Object</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Object</p></td>
<td><p>Hashable object</p></td>
<td><p>Y</p></td>
<td><p>实现了Hashable接口的任意Object</p></td>
<td><p>当前支持Credential，CredentialWrapper，CredentialPojo</p></td>
</tr>
</tbody>
</table>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>evidenceAddress</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>存证地址</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>创建的凭证合约地址</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_CONTRACT_FAILURE_ILLEAGAL_INPUT</p></td>
<td><p>500401</p></td>
<td><p>Evidence参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>
<span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">// 创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">signer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x48f6f6f663ef77409144014ceb063713b65611f8&quot;</span><span class="o">);</span>

<span class="c1">//创建Evidence Address</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseCreateEvidence</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">(),</span> <span class="n">signer</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">String</span> <span class="n">eviAddr</span> <span class="o">=</span> <span class="n">responseCreateEvidence</span><span class="o">.</span><span class="na">getResult</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;3171324536025850958917764441489874006048340539971987768716844&quot;</span><span class="o">)</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">resp</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">addSignature</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">,</span> <span class="n">eviAddr</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30014
   transactionHash: 0x1f9e62fa152eb5fce859dcf81c7c0eddcbcab63c40629d1c745058c227693dae
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用addSignature()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;EvidenceService: 根据凭证Hash计算签名值
EvidenceService-&gt;&gt;区块链节点: 调用智能合约，上传签名值
区块链节点--&gt;&gt;EvidenceService: 返回创建结果
opt 创建失败
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id26">
<h4>5. verify<a class="headerlink" href="#id26" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.verify
接口定义:ResponseData&lt;Boolean&gt; verify(Hashable object, String evidenceAddress)
接口描述: 根据传入的Object计算存证Hash值和链上值对比，验证其是否遭到篡改。当存证包含多个签名时，将会依次验证每个签名，必须确实由签名者列表中的某个WeID所签发才算验证成功。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.Object</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Object</p></td>
<td><p>Hashable object</p></td>
<td><p>Y</p></td>
<td><p>实现了Hashable接口的任意Object</p></td>
<td><p>当前支持Credential，CredentialWrapper，CredentialPojo</p></td>
</tr>
</tbody>
</table>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>evidenceAddress</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>存证地址</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>是否set成功</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuer与签名不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td><p>WeIdentity Document为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>验证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN</p></td>
<td><p>100431</p></td>
<td><p>存证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_HASH_MISMATCH</p></td>
<td><p>100501</p></td>
<td><p>Evidence Hash不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>
<span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:0x30404b47c6c5811d49e28ea2306c804d16618017&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">//创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="n">Credential</span> <span class="n">credential</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">();</span>

<span class="c1">//创建Evidence Address</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseCreateEvidence</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="n">credential</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">String</span> <span class="n">evidenceAddress</span> <span class="o">=</span> <span class="n">responseCreateEvidence</span><span class="o">.</span><span class="na">getResult</span><span class="o">();</span>

<span class="c1">//验证Credential by evidenceAddress</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">responseVerify</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">verify</span><span class="o">(</span><span class="n">credential</span><span class="o">,</span> <span class="n">evidenceAddress</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant WeIdService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用VerifyEvidence()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;EvidenceService: 调用GetEvidence()查询凭证内容
EvidenceService-&gt;&gt;区块链节点: 调用智能合约，查询凭证存证内容
区块链节点--&gt;&gt;EvidenceService: 返回查询结果
opt 查询出错
EvidenceService--&gt;&gt;调用者: 返回验证失败，报错并退出
end
EvidenceService-&gt;&gt;EvidenceService: 生成凭证Hash，与链上凭证Hash对比是否一致
opt Hash不一致
EvidenceService--&gt;&gt;调用者: 返回验证失败，报错并退出
end
EvidenceService-&gt;&gt;WeIdService: 根据存证中签名方信息，调用GetWeIdDocument()查询WeID公钥
WeIdService-&gt;&gt;区块链节点: 调用智能合约，查询WeID公钥
区块链节点--&gt;&gt;WeIdService: 返回查询结果
EvidenceService-&gt;&gt;EvidenceService: 验证存证中签名是否为与凭证Hash一致
opt 验签失败
EvidenceService--&gt;&gt;调用者: 返回验证失败，报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回验证成功
        </div></div>
<div class="section" id="sethashvalue">
<h4>6. setHashValue<a class="headerlink" href="#sethashvalue" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.EvidenceService.setHashValue
接口定义:ResponseData&lt;String&gt; setHashValue(String hashValue, String evidenceAddress, WeIdPrivateKey weIdPrivateKey)
接口描述: 对指定的空存证地址，将其链上的Hash值设定为所传入的Hash值。传入的私钥必须是创建存证时所声明的签名者之一。注意：当存证非空时，接口将返回失败。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>Hashable java.lang.Object</p>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>hashValue</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>存证Hash值</p></td>
<td><p>SHA3算法生成，符合SECP256K1规范，共64个字节，以“0x”开头</p></td>
</tr>
</tbody>
</table>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>evidenceAddress</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>存证地址</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>创建的凭证合约地址</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSACTION_TIMEOUT</p></td>
<td><p>160001</p></td>
<td><p>超时</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSACTION_EXECUTE_ERROR</p></td>
<td><p>160002</p></td>
<td><p>交易错误</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_CONTRACT_FAILURE_ILLEAGAL_INPUT</p></td>
<td><p>500401</p></td>
<td><p>Evidence参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">signer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">signer</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x48f6f6f663ef77409144014ceb063713b65611f8&quot;</span><span class="o">);</span>

<span class="c1">//创建空Evidence</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">emptyEvidenceResp</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="n">signer</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">String</span> <span class="n">eviAddr</span> <span class="o">=</span> <span class="n">emptyEvidenceResp</span><span class="o">.</span><span class="na">getResult</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;3171324536025850958917764441489874006048340539971987768716844&quot;</span><span class="o">);</span>
<span class="n">String</span> <span class="n">hash</span> <span class="o">=</span> <span class="s">&quot;0x1f9e62fa152eb5fce859dcf81c7c0eddcbcab63c40629d1c745058c227693dae&quot;</span><span class="o">;</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">resp</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">setHashValue</span><span class="o">(</span><span class="n">hash</span><span class="o">,</span> <span class="n">eviAddr</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30014
   transactionHash: 0x3e8f711b236fc6fce859dcf81c7c0eddcbcab63c40629d1c745058c338704fbf
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用setHashValue()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService-&gt;&gt;区块链节点: 检查存证是否为空存证
区块链节点--&gt;&gt;EvidenceService: 返回检查结果
opt 非空
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService-&gt;&gt;区块链节点: 设置Hash值
区块链节点--&gt;&gt;EvidenceService: 返回结果
opt 失败
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService-&gt;&gt;区块链节点: 设置根据Hash值生成签名值并设置存证签名
区块链节点--&gt;&gt;EvidenceService: 返回结果
opt 失败
EvidenceService--&gt;&gt;调用者: 报错并退出
end
EvidenceService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="generatehash">
<h4>7. generateHash<a class="headerlink" href="#generatehash" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.EvidenceService.generateHash
接口定义: ResponseData&lt;HashString&gt; generateHash(T object)
接口描述: 将传入的任意Object计算Hash值，不需网络。可以接受**任意Hashable对象**（如凭证）、**File**（Java里的文件实例）、**String**（字符串）。对于不符合类型的入参，将返回类型不支持错误。返回值为HashString，可以直接传入CreateEvidence接口用于存证创建。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>T java.lang.Object</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Object</p></td>
<td><p>T object</p></td>
<td><p>N</p></td>
<td><p>任意Object</p></td>
<td><p>当前支持Hashable，File, String</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;HashString&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>HashString</p></td>
<td><p>创建的符合Hashable接口的存证值对象</p></td>
<td><p>存证值，可以直接传入createEvidence用于存证上链</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>入参非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialService</span> <span class="n">credentialService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialServiceImpl</span><span class="o">();</span>
<span class="n">EvidenceService</span> <span class="n">evidenceService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EvidenceServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialArgs</span> <span class="n">createCredentialArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialArgs</span><span class="o">();</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1561448312461L</span><span class="o">);</span>
<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="c1">// 创建Credential</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>

<span class="c1">// 直接将凭证传入generateHash</span>
<span class="n">HashString</span> <span class="n">hashString</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">generateHash</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredential</span><span class="o">()).</span><span class="na">getResult</span><span class="o">();</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">responseCreateEvidence</span> <span class="o">=</span> <span class="n">evidenceService</span><span class="o">.</span><span class="na">createEvidence</span><span class="o">(</span><span class="n">hashString</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0xa3203e054bb7a7f0dec134c7510299869e343e8d
errorCode: 0
errorMessage: success
transactionInfo:(com.webank.weid.protocol.response.TransactionInfo)
   blockNumber: 30014
   transactionHash: 0x1f9e62fa152eb5fce859dcf81c7c0eddcbcab63c40629d1c745058c227693dae
   transactionIndex: 0
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant EvidenceService
participant 区块链节点
调用者-&gt;&gt;EvidenceService: 调用generateHash()
EvidenceService-&gt;&gt;EvidenceService: 入参非空、格式及合法性检查（Hashable, File, String）
opt 入参校验失败
EvidenceService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
EvidenceService--&gt;&gt;调用者: 返回HashString及成功
        </div></div>
</div>
<div class="section" id="credentialpojoservice">
<h3>CredentialPojoService<a class="headerlink" href="#credentialpojoservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="id27">
<h4>1. createCredential<a class="headerlink" href="#id27" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.createCredential
接口定义:&lt;T&gt; ResponseData&lt;CredentialPojo&gt; createCredential(CreateCredentialPojoArgs&lt;T&gt; args)
接口描述: 根据传入的claim对象生成Credential。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>com.webank.weid.protocol.request.CreateCredentialPojoArgs&lt;T&gt;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>CPT ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期时间</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>T</p></td>
<td><p>Y</p></td>
<td><p>创建凭证需要的claim数据，参数类型为泛型，为POJO对象（不同的CPT对应不同的POJO类）。</p></td>
<td><p>需要通过build-tool工具根据CPT ID生成对应的jar包，</p></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>weId身份信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;CredentialPojo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CredentialPojo</p></td>
<td><p>凭证对象</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥和weid不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>credential处理未知异常</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialPojo)
   context: https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1
   id: 04a3e89d-825a-49fe-b8f5-8ccb9f487a52
   cptId: 1017
   issuer: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
   issuanceDate: 1560420878712
   expirationDate: 1560470944120
   claim:(java.util.HashMap)
      gender: F
      name: zhangsan
      age: 22
   proof:(java.util.HashMap)
      creator: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0
      salt:(java.util.HashMap)
         gender: ibu7f
         name: el1w8
         age: ajqkr
      created: 1560420878712
      type: Secp256k1
      signatureValue: G7UPiw08P5E9dEcSJEo9zpKu/nsUrpn00xDE+mwDXn9gJEohIlRUX5XTGQB4G1w3yThp6R/2RqjUYkuQTaUXbIU=
   type:(java.util.ArrayList)
      [0]:VerifiableCredential
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用CreateCredential()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 为claim中的每个字段生成盐值
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成签发日期、生成数字签名
CredentialPojoService--&gt;&gt;调用者: 返回凭证
        </div></div>
<hr class="docutils" />
<div class="section" id="createselectivecredential">
<h4>2. createSelectiveCredential<a class="headerlink" href="#createselectivecredential" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.createSelectiveCredential
接口定义: ResponseData&lt;CredentialPojo&gt; createSelectiveCredential(CredentialPojo credentialPojo, ClaimPolicy claimPolicy)
接口描述: 通过原始凭证和披漏策略，创建选择性披露的Credential。
</pre></div>
</div>
<p>..note:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>注意：对于已经创建好的选择性披露凭证，不允许再次进行选择性披露。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.ClaimPolicy</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>fieldsToBeDisclosed</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>披露配置</p></td>
<td><p>根据claim匹配的结构，详见调用示例</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;CredentialPojo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>CredentialPojo</p></td>
<td><p>凭证对象</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_POLICY_NOT_EXIST</p></td>
<td><p>100420</p></td>
<td><p>披露策略为null</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_POLICY_DISCLOSUREVALUE_ILLEGAL</p></td>
<td><p>100423</p></td>
<td><p>policy披露信息非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_POLICY_FORMAT_DOSE_NOT_MATCH_CLAIM</p></td>
<td><p>100427</p></td>
<td><p>披露策略与Claim不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_DISCLOSURE_DATA_TYPE_ILLEGAL</p></td>
<td><p>100428</p></td>
<td><p>披露数据格式错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span>
     <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span>
     <span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span>
     <span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span>
     <span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span>
     <span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span>
         <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="c1">// 选择性披露</span>
<span class="n">ClaimPolicy</span> <span class="n">claimPolicy</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ClaimPolicy</span><span class="o">();</span>
<span class="n">claimPolicy</span><span class="o">.</span><span class="na">setFieldsToBeDisclosed</span><span class="o">(</span><span class="s">&quot;{\&quot;name\&quot;:1,\&quot;gender\&quot;:0,\&quot;age\&quot;:1}&quot;</span><span class="o">);</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">selectiveResponse</span> <span class="o">=</span>
         <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createSelectiveCredential</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">(),</span> <span class="n">claimPolicy</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialPojo)
   context: https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1
   id: c4f8ca00-7c1b-4ba0-993f-008106075d9c
   cptId: 1017
   issuer: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
   issuanceDate: 1560420975268
   expirationDate: 1560471040676
   claim:(java.util.HashMap)
      gender: 0x0756ccf78a0ebd5bd186b054376f1e9d86139bf04f660e9171a74673e5a21c75
      name: zhangsan
      age: 22
   proof:(java.util.HashMap)
      creator: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0
      salt:(java.util.HashMap)
         gender: 0
         name: rr3g0
         age: 9ysgr
      created: 1560420975268
      type: Secp256k1
      signatureValue: GxVcZJFEnC7w+ZKOZAjmKy5JfFxoEFqffmCMvbUnVYmzEVKIUtDCiDmokZ2X3jIV/uFvUHQ4DWXksrD6Opr1vLo=
   type:(java.util.ArrayList)
      [0]:VerifiableCredential
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用createSelectiveCredential()，传入原始凭证
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 根据claimPolicy来隐藏不披露的字段
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成签发日期、生成数字签名
CredentialPojoService--&gt;&gt;调用者: 返回凭证
        </div></div>
<hr class="docutils" />
<div class="section" id="id28">
<h4>3. verify<a class="headerlink" href="#id28" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.verify
接口定义: ResponseData&lt;Boolean&gt; verify(String issuerWeId, CredentialPojo credential)
接口描述: 验证credential。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>issuerWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>验证结果</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CPT_NOT_EXISTS</p></td>
<td><p>100416</p></td>
<td><p>cpt不存在</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名验证不通过</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>签名验证异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SALT_ILLEGAL</p></td>
<td><p>100430</p></td>
<td><p>盐值非法</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">responseVerify</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">verify</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
participant CptService
participant WeIdService
participant 区块链节点
调用者-&gt;&gt;CredentialPojoService: 调用verify()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;WeIdService: 查询WeIdentity DID存在性
WeIdService-&gt;&gt;区块链节点: 调用智能合约，查询WeIdentity DID属性
区块链节点--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;CredentialPojoService: 返回查询结果
opt 查询不存在
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CptService: 查询CPT存在性及Claim关联语义
CptService-&gt;&gt;区块链节点: 调用智能合约，查询CPT
区块链节点--&gt;&gt;CptService: 返回查询结果
CptService--&gt;&gt;CredentialPojoService: 返回查询结果
opt 不符合CPT格式要求
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 验证过期、撤销与否
opt 任一验证失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
opt 未提供验签公钥
CredentialPojoService-&gt;&gt;WeIdService: 查询Issuer对应公钥
WeIdService-&gt;&gt;区块链节点: 调用智能合约，查询Issuer的WeIdentity DID Document
区块链节点--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;CredentialPojoService: 返回查询结果
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 通过公钥与签名对比，验证Issuer是否签发此凭证
opt 验证签名失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id29">
<h4>4. verify<a class="headerlink" href="#id29" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.verify
接口定义: ResponseData&lt;Boolean&gt; verify(WeIdPublicKey issuerPublicKey, CredentialPojo credential)
接口描述: 使用指定公钥验证credentialWrapper。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>com.webank.weid.protocol.base.WeIdPublicKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>publicKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>公钥</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>验证结果</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名验证不通过</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CPT_NOT_EXISTS</p></td>
<td><p>100416</p></td>
<td><p>cpt不存在</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td><p>获取weIdDocument异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>签名验证异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PUBLIC_KEY_NOT_EXISTS</p></td>
<td><p>100421</p></td>
<td><p>公钥不存在</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SALT_ILLEGAL</p></td>
<td><p>100430</p></td>
<td><p>盐值非法</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhangsan&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">WeIdPublicKey</span> <span class="n">weIdPublicKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPublicKey</span><span class="o">();</span>
<span class="n">weIdPublicKey</span><span class="o">.</span><span class="na">setPublicKey</span><span class="o">(</span><span class="s">&quot;9202079291855274840499629257327649367489192973501473466426182121217769706994308329953406897395674428921435762028726727399019951049448689033610431403383875&quot;</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">responseVerify</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">verify</span><span class="o">(</span><span class="n">weIdPublicKey</span><span class="o">,</span> <span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
participant CptService
participant 区块链节点
调用者-&gt;&gt;CredentialPojoService: 调用verify()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CptService: 查询CPT存在性及Claim关联语义
CptService-&gt;&gt;区块链节点: 调用智能合约，查询CPT
区块链节点--&gt;&gt;CptService: 返回查询结果
CptService--&gt;&gt;CredentialPojoService: 返回查询结果
opt 不符合CPT格式要求
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 验证过期、撤销与否
opt 任一验证失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 通过公钥与签名对比，验证Issuer是否签发此凭证
opt 验证签名失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id30">
<h4>5. verify<a class="headerlink" href="#id30" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.verify
接口定义: ResponseData&lt;Boolean&gt; verify(String presenterWeId, PresentationPolicyE presentationPolicyE, Challenge challenge, PresentationE presentationE)
接口描述: 验证Presentation。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>presenterWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>用户的WeIdentity DID</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PresentationPolicyE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>polcyId</p></td>
<td><p>策略编号</p></td>
</tr>
<tr class="row-odd"><td><p>orgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构编号</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>policyPublisherWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>创建policy机构的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>policy</p></td>
<td><p>Map&lt;Integer, ClaimPolicy&gt;</p></td>
<td><p>Y</p></td>
<td><p>策略配置</p></td>
<td><p>key: CPTID, value: 披露策略对象</p></td>
</tr>
<tr class="row-odd"><td><p>extra</p></td>
<td><p>Map&lt;String, String&gt;</p></td>
<td><p>N</p></td>
<td><p>扩展字段</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Challenge</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>policy提供给指定的WeIdentity DID</p></td>
</tr>
<tr class="row-odd"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>nonce</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>随机字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PresentationE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td><p>上下文</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td><p>Presentation Type</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>credentialList</p></td>
<td><p>List&lt;CredentialPojo&gt;</p></td>
<td><p>Y</p></td>
<td><p>凭证列表</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Presentation的签名信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>验证结果</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名验证不通过</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CPT_NOT_EXISTS</p></td>
<td><p>100416</p></td>
<td><p>cpt不存在</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_WEID_DOCUMENT_ILLEGAL</p></td>
<td><p>100417</p></td>
<td><p>获取weIdDocument异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXCEPTION_VERIFYSIGNATURE</p></td>
<td><p>100419</p></td>
<td><p>签名验证异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_NOT_EXISTS</p></td>
<td><p>100422</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_POLICY_DISCLOSUREVALUE_ILLEGAL</p></td>
<td><p>100423</p></td>
<td><p>policy披露信息非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_DISCLOSUREVALUE_NOTMATCH_SALTVALUE</p></td>
<td><p>100424</p></td>
<td><p>Credential披露信息跟盐信息不一致</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CPTID_NOTMATCH</p></td>
<td><p>100425</p></td>
<td><p>CPT不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_PRESENTERWEID_NOTMATCH</p></td>
<td><p>100426</p></td>
<td><p>presenterWeId跟challenge不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SALT_ILLEGAL</p></td>
<td><p>100430</p></td>
<td><p>盐值非法</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>PRESENTATION_CHALLENGE_NONCE_MISMATCH</p></td>
<td><p>100605</p></td>
<td><p>challenge随机数不匹配</p></td>
</tr>
<tr class="row-even"><td><p>PRESENTATION_SIGNATURE_MISMATCH</p></td>
<td><p>100606</p></td>
<td><p>presentation验签失败</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationERes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//验证Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">Boolean</span><span class="o">&gt;</span> <span class="n">verifyRes</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">verify</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">presentationERes</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: true
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
participant CptService
participant 区块链节点
调用者-&gt;&gt;CredentialPojoService: 调用verify()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
loop 遍历credentialPojo列表
CredentialPojoService-&gt;&gt;CredentialPojoService: 验证policy和claim里的key是否一致
opt 任一验证失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CptService: 查询CPT存在性及Claim关联语义
CptService-&gt;&gt;区块链节点: 调用智能合约，查询CPT
区块链节点--&gt;&gt;CptService: 返回查询结果
CptService--&gt;&gt;CredentialPojoService: 返回查询结果
opt 不符合CPT格式要求
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 验证过期、撤销与否
opt 任一验证失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 通过公钥与签名对比，验证Issuer是否签发此凭证
opt 验证签名失败
CredentialPojoService--&gt;&gt;调用者: 报错并退出
end
end
CredentialPojoService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="createpresentation">
<h4>6. createPresentation<a class="headerlink" href="#createpresentation" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.createPresentation
接口定义: ResponseData&lt;PresentationE&gt; createPresentation(List&lt;CredentialPojo&gt; credentialList, PresentationPolicyE presentationPolicyE, Challenge challenge, WeIdAuthentication weIdAuthentication)
接口描述: 创建Presentation。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.uitl.List&lt;com.webank.weid.protocol.base.CredentialPojo&gt;</p>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PresentationPolicyE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>polcyId</p></td>
<td><p>策略编号</p></td>
</tr>
<tr class="row-odd"><td><p>orgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>机构编号</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>policyPublisherWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>创建policy机构的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>policy</p></td>
<td><p>Map&lt;Integer, ClaimPolicy&gt;</p></td>
<td><p>Y</p></td>
<td><p>策略配置</p></td>
<td><p>key: CPTID, value: 披露策略对象</p></td>
</tr>
<tr class="row-odd"><td><p>extra</p></td>
<td><p>Map&lt;String, String&gt;</p></td>
<td><p>N</p></td>
<td><p>扩展字段</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Challenge</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>N</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>policy提供给指定的WeIdentity DID</p></td>
</tr>
<tr class="row-odd"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>nonce</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>随机字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;PresentationE&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>PresentationE</p></td>
<td><p>创建的Presentation</p></td>
<td><p>业务数据</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PresentationE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>上下文</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Presentation Type</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>credentialList</p></td>
<td><p>List&lt;CredentialPojo&gt;</p></td>
<td><p>凭证列表</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Presentation的签名信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>用户weId不匹配其私钥</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_POLICY_NOT_EXIST</p></td>
<td><p>100420</p></td>
<td><p>披露策略为null</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_POLICY_FORMAT_DOSE_NOT_MATCH_CLAIM</p></td>
<td><p>100427</p></td>
<td><p>披露策略与Claim不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>PRESENTATION_CHALLENGE_INVALID</p></td>
<td><p>100600</p></td>
<td><p>challenge无效</p></td>
</tr>
<tr class="row-even"><td><p>PRESENTATION_CHALLENGE_WEID_MISMATCH</p></td>
<td><p>100601</p></td>
<td><p>challenge中的weId不匹配用户的weId</p></td>
</tr>
<tr class="row-odd"><td><p>PRESENTATION_POLICY_INVALID</p></td>
<td><p>100602</p></td>
<td><p>policy无效</p></td>
</tr>
<tr class="row-even"><td><p>PRESENTATION_CREDENTIALLIST_MISMATCH_CLAIM_POLICY</p></td>
<td><p>100603</p></td>
<td><p>credentialList不匹配Policy</p></td>
</tr>
<tr class="row-odd"><td><p>PRESENTATION_WEID_PUBLICKEY_ID_INVALID</p></td>
<td><p>100604</p></td>
<td><p>公钥编号无效</p></td>
</tr>
<tr class="row-even"><td><p>PRESENTATION_POLICY_PUBLISHER_WEID_INVALID</p></td>
<td><p>100609</p></td>
<td><p>policy中的publisherWeId无效</p></td>
</tr>
<tr class="row-odd"><td><p>PRESENTATION_POLICY_PUBLISHER_WEID_NOT_EXIST</p></td>
<td><p>100610</p></td>
<td><p>policy中的publisherWeId不存在</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credentialList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>

<span class="c1">//创建Challenge</span>
<span class="n">Challenge</span> <span class="n">challenge</span> <span class="o">=</span> <span class="n">Challenge</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()));</span>

<span class="c1">//创建PresentationPolicyE</span>
<span class="n">String</span> <span class="n">policyJson</span> <span class="o">=</span> <span class="s">&quot;{\&quot;extra\&quot; : {\&quot;extra1\&quot; : \&quot;\&quot;,\&quot;extra2\&quot; : \&quot;\&quot;},\&quot;id\&quot; : 123456,\&quot;version\&quot; : 1,\&quot;orgId\&quot; : \&quot;webank\&quot;,\&quot;weId\&quot; : \&quot;did:weid:0x0231765e19955fc65133ec8591d73e9136306cd0\&quot;,\&quot;policy\&quot; : {\&quot;1017\&quot; : {\&quot;fieldsToBeDisclosed\&quot; : {\&quot;gender\&quot; : 0,\&quot;name\&quot; : 1,\&quot;age\&quot; : 0}}}}&quot;</span><span class="o">;</span>
<span class="n">PresentationPolicyE</span> <span class="n">presentationPolicyE</span> <span class="o">=</span> <span class="n">PresentationPolicyE</span><span class="o">.</span><span class="na">fromJson</span><span class="o">(</span><span class="n">policyJson</span><span class="o">);</span>

<span class="c1">//创建Presentation</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span>  <span class="n">presentationE</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createPresentation</span><span class="o">(</span><span class="n">credentialList</span><span class="o">,</span> <span class="n">presentationPolicyE</span><span class="o">,</span> <span class="n">challenge</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.PresentationE)
   context:(java.util.ArrayList)
      [0]:https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1
   type:(java.util.ArrayList)
      [0]:VerifiablePresentation
   verifiableCredential:(java.util.ArrayList)
      [0]:com.webank.weid.protocol.base.CredentialPojo
         context: https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1
         id: 67598cc5-a922-4e9f-ae0a-90c6285a8236
         cptId: 1017
         issuer: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7
         issuanceDate: 1560425696276
         expirationDate: 1560475761684
         claim:(java.util.HashMap)
            gender: 0x8dba4ce05ca123e0c48b877f461e1b8c362fcab9d03330dcb80d7d039081f50b
            name: zhangsan
            age: 0xdeb5a47d7ab03d9fefe2169cc59db146cec6f24005bcf0b2e2a0c95bfe7adde5
         proof:(java.util.HashMap)
            creator: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0
            salt:(java.util.HashMap)
               gender: 0
               name: yjckg
               age: 0
            created: 1560425696276
            type: Secp256k1
            signatureValue: HCgmoX0f7ZYkwpd+pJ2+RCRKNt5lf9nbl8g9YWTSuA32IIoRSjMr7GPZVbe5bcu+hD/pnkAJbbinJo4/YqOOync=
         type:(java.util.ArrayList)
            [0]:VerifiableCredential
   proof:(java.util.HashMap)
      created: 1560425696412
      type: Secp256k1
      verificationMethod: did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0
      nonce: DJulONVxD2TFidB8vaYH
      signatureValue: G8ivS1e625NT8qSzLEugbqkRW6HDJNA4Lfcl7uCXV+uEffPMVF6Bwnk0pyCOd+4bbw90pMaj+EVxeL79acYPzM4=
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用verify()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
loop 遍历credentialPojo列表
CredentialPojoService-&gt;&gt;CredentialPojoService: 根据credentialPojo中的cptId获取对应的claimPolicy
opt claimPolicy
CredentialPojoService--&gt;&gt;调用者: continue
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 根据claimPolicy，调用createSelectiveCredential()方法，做选择性披露
opt 选择性披露失败
CredentialPojoService--&gt;&gt;调用者: 失败退出
end
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 设置context等元数据属性
CredentialPojoService-&gt;&gt;CredentialPojoService: 对presentation整体签名，放入proof结构，同时设置其他proof属性，用于验证
CredentialPojoService--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="getcredentialpojohash">
<h4>7. getCredentialPojoHash<a class="headerlink" href="#getcredentialpojohash" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.getCredentialPojoHash
接口定义:ResponseData&lt;String&gt; getCredentialHash(CredentialPojo args)
接口描述: 传入CredentialPojo信息生成CredentialPojo整体的Hash值，一般在生成Evidence时调用。
</pre></div>
</div>
<p><strong>接口入参</strong>:   com.webank.weid.protocol.base.CredentialPojo</p>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>type</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>Y</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-even"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>issuer 的 WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>返回结果值</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EXPIRED</p></td>
<td><p>100402</p></td>
<td><p>过期</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SIGNATURE_BROKEN</p></td>
<td><p>100405</p></td>
<td><p>签名破坏</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期格式非法</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ID_NOT_EXISTS</p></td>
<td><p>100412</p></td>
<td><p>ID为空</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CONTEXT_NOT_EXISTS</p></td>
<td><p>100413</p></td>
<td><p>context为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_SIGNATURE_TYPE_ILLEGAL</p></td>
<td><p>100429</p></td>
<td><p>验证签名类型异常</p></td>
</tr>
<tr class="row-odd"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>
<span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">&lt;</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;&gt;();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">currentTimeMillis</span><span class="o">()</span> <span class="o">+</span> <span class="mi">1000</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">100</span><span class="o">);</span>

<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPublicKeyId</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7#key0&quot;</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdAuthentication</span><span class="o">(</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;();</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">22</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>

<span class="c1">//创建CredentialPojo</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredential</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">resp</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">getCredentialPojoHash</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">());</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result: 0x06173e4b714d57565ae5ddf23c4e84cb0a9824cb72eab476303d2dd1cc0a4728
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用GetCredentialPojoHash()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成凭证Hash
CredentialPojoService--&gt;&gt;调用者: 返回凭证Hash
        </div></div>
<div class="section" id="id31">
<h4>8. addSignature<a class="headerlink" href="#id31" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.addSignature
接口定义:ResponseData&lt;Credential&gt; addSignature(List&lt;Credential&gt; credentialList, WeIdPrivateKey weIdPrivateKey)
接口描述:多签，在原凭证列表的基础上，创建包裹成一个新的多签凭证，由传入的私钥所签名。此凭证的CPT为一个固定值。在验证一个多签凭证时，会迭代验证其包裹的所有子凭证。本接口不支持创建选择性披露的多签凭证。
</pre></div>
</div>
<p><strong>接口入参</strong>:   java.util.ArrayList</p>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdPrivateKey</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>privateKey</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>私钥值</p></td>
<td><p>使用十进制数字表示</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;Credential&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Credential</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.TransactionInfo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>blockNumber</p></td>
<td><p>BigInteger</p></td>
<td><p>交易块高</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>transactionHash</p></td>
<td><p>String</p></td>
<td><p>交易hash</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>transactionIndex</p></td>
<td><p>BigInteger</p></td>
<td><p>交易索引</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Credential</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td><p>默认为106</p></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>JsonSchema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialPojoArgs</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1551448312461L</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredentialPojo</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">credList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredentialPojo</span><span class="o">());</span>
<span class="n">Long</span> <span class="n">expirationDate</span> <span class="o">=</span> <span class="n">DateUtils</span><span class="o">.</span><span class="na">convertToNoMillisecondTimeStamp</span><span class="o">(</span>
   <span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">getExpirationDate</span><span class="o">()</span> <span class="o">+</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">expirationDate</span><span class="o">);</span>
<span class="n">CredentialPojo</span> <span class="n">tempCredential</span> <span class="o">=</span>
    <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredentialPojo</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">).</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredentialPojo</span><span class="o">();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">tempCredential</span><span class="o">);</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">multiSignedResp</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">addSignature</span><span class="o">(</span><span class="n">credList</span><span class="o">,</span> <span class="n">weIdPrivateKey</span><span class="o">);</span>
<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">multiSignedResp</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialPojo)
   credentialPojo:(com.webank.weid.protocol.base.CredentialPojo) {
   {
     &quot;claim&quot;: {
       &quot;credentialList&quot;: [
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 1,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33&quot;,
             &quot;name&quot;: &quot;1&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000087,
           &quot;expirationDate&quot;: 1567491752,
           &quot;id&quot;: &quot;6ea6e209-10e9-4a93-b6be-12af1a32655b&quot;,
           &quot;issuanceDate&quot;: 1567405352,
           &quot;issuer&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: 1567405352,
             &quot;creator&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33#keys-0&quot;,
             &quot;salt&quot;: {
               &quot;age&quot;: &quot;yOwN7&quot;,
               &quot;gender&quot;: &quot;jjB85&quot;,
               &quot;id&quot;: &quot;BmRYI&quot;,
               &quot;name&quot;: &quot;BjYqF&quot;
             },
             &quot;signatureValue&quot;: &quot;G+SNG3rBZNDvRNgRtJugPtX1FmE8XJIkV4CGPK\/nt\/breIPMJ5wYxImTp2QAxBUe5HMwCe9PPGhhMJJAazM5u9k=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           },
           &quot;type&quot;: [
             &quot;VerifiableCredential&quot;
           ]
         },
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 1,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53&quot;,
             &quot;name&quot;: &quot;1&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000087,
           &quot;expirationDate&quot;: 1567491842,
           &quot;id&quot;: &quot;a3544a9c-6cb6-4688-9622-bb935fb0d93f&quot;,
           &quot;issuanceDate&quot;: 1567405355,
           &quot;issuer&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: 1567405355,
             &quot;creator&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53#keys-0&quot;,
             &quot;salt&quot;: {
               &quot;age&quot;: &quot;5nImi&quot;,
               &quot;gender&quot;: &quot;Me224&quot;,
               &quot;id&quot;: &quot;5pYs2&quot;,
               &quot;name&quot;: &quot;z6VmW&quot;
             },
             &quot;signatureValue&quot;: &quot;HC8OAG\/dRmteGSIGWIDekp8fC1KJI8EEDZBb29HiTLXvVj350l9yTOHeGSBCr2VRY\/DSHT5ONjlvcrO4Mqa3Auo=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           },
           &quot;type&quot;: [
             &quot;VerifiableCredential&quot;
           ]
         }
       ]
     },
     &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
     &quot;cptId&quot;: 107,
     &quot;expirationDate&quot;: 1567491842,
     &quot;id&quot;: &quot;ad5d5a54-4574-4b3b-b1df-9d0687b6a0ac&quot;,
     &quot;issuanceDate&quot;: 1567405359,
     &quot;issuer&quot;: &quot;did:weid:1:0x4e9a111867ed6370e1e23f7a79426f6649eb78c6&quot;,
     &quot;proof&quot;: {
       &quot;created&quot;: 1567405359,
       &quot;creator&quot;: &quot;did:weid:1:0x4e9a111867ed6370e1e23f7a79426f6649eb78c6#keys-0&quot;,
       &quot;salt&quot;: {
         &quot;credentialList&quot;: &quot;&quot;
       },
       &quot;signatureValue&quot;: &quot;HC1y3rfyb\/2sg+E2Uulczm8VDtmQ6VrU\/9ow4e4nP3lVUOv4Gz41pfBrJHnV4wQoUbQsCYpezFx5sdaUwUILV1I=&quot;,
       &quot;type&quot;: &quot;Secp256k1&quot;
     },
     &quot;type&quot;: [
       &quot;VerifiableCredential&quot;
     ]
   }
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用addSignature()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成签发日期、以原凭证列表为Claim生成数字签名
CredentialPojoService--&gt;&gt;调用者: 返回凭证
        </div></div>
<div class="section" id="createtrustedtimestamp">
<h4>9. createTrustedTimestamp<a class="headerlink" href="#createtrustedtimestamp" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.CredentialPojoService.createTrustedTimestamp
接口定义:ResponseData&lt;CredentialPojo&gt; createTrustedTimestamp(List&lt;CredentialPojo&gt; credentialList, WeIdAuthentication weIdAuthentication)
接口描述: 使用第三方可信时间戳服务，创建一个可信时间戳凭证。
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>注意：本服务需要您先行配置好时间戳服务的相关参数，请参见<a class="reference external" href="https://weidentity.readthedocs.io/zh_CN/latest/docs/faq-java.html">时间戳服务配置步骤</a>。当前，可信时间戳服务支持使用WeSign（微鉴证）集成。</p>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>注意：创建可信时间戳凭证的输入参数是一个凭证list。当前，因为一些技术限制，还不支持对**已经选择性披露的凭证**进行可信时间戳的创建。也就是说，如果您传入的凭证list里面有任何一个凭证是选择性披露的，那么创建将会失败。</p>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>注意：对于已经创建好的可信时间戳凭证，您可以通过调用createSelectiveCredential对其进行选择性披露。</p>
</div>
<p><strong>接口入参</strong>:   java.util.ArrayList</p>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.WeIdAuthentication</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>CPT发布者的WeIdentity DID</p></td>
<td><p>WeIdentity DID的格式传入</p></td>
</tr>
<tr class="row-odd"><td><p>weIdPublicKeyId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>公钥Id</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdPrivateKey</p></td>
<td><p>WeIdPrivateKey</p></td>
<td><p>Y</p></td>
<td></td>
<td><p>交易私钥，见下</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:    com.webank.weid.protocol.response.ResponseData&lt;CredentialPojo&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Credential</p></td>
<td></td>
<td><p>见下</p></td>
</tr>
<tr class="row-odd"><td><p>transactionInfo</p></td>
<td><p>TransactionInfo</p></td>
<td><p>交易信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.CredentialPojo</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>context</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>版本</p></td>
<td><p>默认为v1</p></td>
</tr>
<tr class="row-odd"><td><p>id</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>证书ID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>cptId</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>cptId</p></td>
<td><p>默认为106</p></td>
</tr>
<tr class="row-odd"><td><p>issuer</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>WeIdentity DID</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>issuanceDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>创建日期</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>expirationDate</p></td>
<td><p>Long</p></td>
<td><p>Y</p></td>
<td><p>到期日期</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>claim</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>Claim数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>proof</p></td>
<td><p>Map&lt;String, Object&gt;</p></td>
<td><p>Y</p></td>
<td><p>签名数据结构体</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CPT_JSON_SCHEMA_INVALID</p></td>
<td><p>100301</p></td>
<td><p>JsonSchema无效</p></td>
</tr>
<tr class="row-even"><td><p>CPT_ID_ILLEGAL</p></td>
<td><p>100303</p></td>
<td><p>cptId无效</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ERROR</p></td>
<td><p>100400</p></td>
<td><p>Credential标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CREATE_DATE_ILLEGAL</p></td>
<td><p>100408</p></td>
<td><p>创建日期格式非法</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EXPIRE_DATE_ILLEGAL</p></td>
<td><p>100409</p></td>
<td><p>到期日期无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_CLAIM_NOT_EXISTS</p></td>
<td><p>100410</p></td>
<td><p>Claim数据不能为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_CLAIM_DATA_ILLEGAL</p></td>
<td><p>100411</p></td>
<td><p>Claim数据无效</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_PRIVATE_KEY_NOT_EXISTS</p></td>
<td><p>100415</p></td>
<td><p>私钥为空</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_INVALID</p></td>
<td><p>100418</p></td>
<td><p>WeIdentity DID无效</p></td>
</tr>
<tr class="row-even"><td><p>TIMESTAMP_SERVICE_BASE_ERROR</p></td>
<td><p>100433</p></td>
<td><p>时间戳服务一般错误，请参照log检查具体错误</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_SYSTEM_CPT_CLAIM_VERIFY_ERROR</p></td>
<td><p>100434</p></td>
<td><p>凭证签名验证通过，但是内部系统CPT内容验证失败</p></td>
</tr>
<tr class="row-even"><td><p>TIMESTAMP_SERVICE_UNCONFIGURED</p></td>
<td><p>100435</p></td>
<td><p>时间戳服务未配置</p></td>
</tr>
<tr class="row-odd"><td><p>TIMESTAMP_SERVICE_WESIGN_ERROR</p></td>
<td><p>100436</p></td>
<td><p>时间戳服务微鉴证侧出错，请参照log检查具体错误</p></td>
</tr>
<tr class="row-even"><td><p>TIMESTAMP_VERIFICATION_FAILED</p></td>
<td><p>100437</p></td>
<td><p>时间戳验证不通过（可能是hash值/时间/时间戳签名任一错误）</p></td>
</tr>
<tr class="row-odd"><td><p>TIMESTAMP_CREATION_FAILED_FOR_SELECTIVELY_DISCLOSED</p></td>
<td><p>100438</p></td>
<td><p>时间戳服务不支持对已经选择性披露的凭证进行创建时间戳</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数为空</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">CredentialPojoService</span> <span class="n">credentialPojoService</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CredentialPojoServiceImpl</span><span class="o">();</span>

<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">claim</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;(</span><span class="mi">3</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;name&quot;</span><span class="o">,</span> <span class="s">&quot;zhang san&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;gender&quot;</span><span class="o">,</span> <span class="s">&quot;F&quot;</span><span class="o">);</span>
<span class="n">claim</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">&quot;age&quot;</span><span class="o">,</span> <span class="mi">18</span><span class="o">);</span>

<span class="n">CreateCredentialPojoArgs</span> <span class="n">createCredentialPojoArgs</span> <span class="o">=</span> <span class="k">new</span> <span class="n">CreateCredentialPojoArgs</span><span class="o">();</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setClaim</span><span class="o">(</span><span class="n">claim</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setCptId</span><span class="o">(</span><span class="mi">1017</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="mi">1551448312461L</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setIssuer</span><span class="o">(</span><span class="s">&quot;did:weid:101:0x39e5e6f663ef77409144014ceb063713b65600e7&quot;</span><span class="o">);</span>

<span class="n">WeIdPrivateKey</span> <span class="n">weIdPrivateKey</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdPrivateKey</span><span class="o">();</span>
<span class="n">weIdPrivateKey</span><span class="o">.</span><span class="na">setPrivateKey</span><span class="o">(</span><span class="s">&quot;60866441986950167911324536025850958917764441489874006048340539971987791929772&quot;</span><span class="o">);</span>

<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>

<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialWrapper</span><span class="o">&gt;</span> <span class="n">response</span> <span class="o">=</span> <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredentialPojo</span><span class="o">(</span><span class="n">createCredentialArgs</span><span class="o">);</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">credList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;();</span>
<span class="n">credList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredentialPojo</span><span class="o">());</span>
<span class="n">Long</span> <span class="n">expirationDate</span> <span class="o">=</span> <span class="n">DateUtils</span><span class="o">.</span><span class="na">convertToNoMillisecondTimeStamp</span><span class="o">(</span>
   <span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">getExpirationDate</span><span class="o">()</span> <span class="o">+</span> <span class="mi">24</span> <span class="o">*</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">60</span><span class="o">);</span>
<span class="n">createCredentialPojoArgs</span><span class="o">.</span><span class="na">setExpirationDate</span><span class="o">(</span><span class="n">expirationDate</span><span class="o">);</span>
<span class="n">CredentialPojo</span> <span class="n">tempCredential</span> <span class="o">=</span>
    <span class="n">credentialPojoService</span><span class="o">.</span><span class="na">createCredentialPojo</span><span class="o">(</span><span class="n">createCredentialPojoArgs</span><span class="o">).</span><span class="na">getResult</span><span class="o">().</span><span class="na">getCredentialPojo</span><span class="o">();</span>
<span class="n">credentialList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">tempCredential</span><span class="o">);</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>
<span class="n">weIdAuthentication</span><span class="o">.</span><span class="na">setWeIdPrivateKey</span><span class="o">(</span><span class="n">weIdPrivateKey</span><span class="o">);</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">CredentialPojo</span><span class="o">&gt;</span> <span class="n">trustedCred</span> <span class="o">=</span> <span class="n">credentialService</span><span class="o">.</span><span class="na">createTrustedTimestamp</span><span class="o">(</span><span class="n">credList</span><span class="o">,</span> <span class="n">weIdAuthentication</span><span class="o">);</span>
<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">trustedCred</span><span class="o">);</span>
</pre></div>
</div>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>返回结果如：
result:(com.webank.weid.protocol.base.CredentialPojo)
   credentialPojo:(com.webank.weid.protocol.base.CredentialPojo) {
   {
     &quot;claim&quot;: {
       &quot;credentialList&quot;: [
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 1,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33&quot;,
             &quot;name&quot;: &quot;1&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000087,
           &quot;expirationDate&quot;: 1567491752,
           &quot;id&quot;: &quot;6ea6e209-10e9-4a93-b6be-12af1a32655b&quot;,
           &quot;issuanceDate&quot;: 1567405352,
           &quot;issuer&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: 1567405352,
             &quot;creator&quot;: &quot;did:weid:1:0xa4c2666560499868baf1906941f806b6d1c26e33#keys-0&quot;,
             &quot;salt&quot;: {
               &quot;age&quot;: &quot;yOwN7&quot;,
               &quot;gender&quot;: &quot;jjB85&quot;,
               &quot;id&quot;: &quot;BmRYI&quot;,
               &quot;name&quot;: &quot;BjYqF&quot;
             },
             &quot;signatureValue&quot;: &quot;G+SNG3rBZNDvRNgRtJugPtX1FmE8XJIkV4CGPK\/nt\/breIPMJ5wYxImTp2QAxBUe5HMwCe9PPGhhMJJAazM5u9k=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           },
           &quot;type&quot;: [
             &quot;VerifiableCredential&quot;
           ]
         },
         {
           &quot;claim&quot;: {
             &quot;age&quot;: 1,
             &quot;gender&quot;: &quot;F&quot;,
             &quot;id&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53&quot;,
             &quot;name&quot;: &quot;1&quot;
           },
           &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
           &quot;cptId&quot;: 2000087,
           &quot;expirationDate&quot;: 1567491842,
           &quot;id&quot;: &quot;a3544a9c-6cb6-4688-9622-bb935fb0d93f&quot;,
           &quot;issuanceDate&quot;: 1567405355,
           &quot;issuer&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53&quot;,
           &quot;proof&quot;: {
             &quot;created&quot;: 1567405355,
             &quot;creator&quot;: &quot;did:weid:1:0x309320a01f215a380c6950e80a89181ad8a8cd53#keys-0&quot;,
             &quot;salt&quot;: {
               &quot;age&quot;: &quot;5nImi&quot;,
               &quot;gender&quot;: &quot;Me224&quot;,
               &quot;id&quot;: &quot;5pYs2&quot;,
               &quot;name&quot;: &quot;z6VmW&quot;
             },
             &quot;signatureValue&quot;: &quot;HC8OAG\/dRmteGSIGWIDekp8fC1KJI8EEDZBb29HiTLXvVj350l9yTOHeGSBCr2VRY\/DSHT5ONjlvcrO4Mqa3Auo=&quot;,
             &quot;type&quot;: &quot;Secp256k1&quot;
           },
           &quot;type&quot;: [
             &quot;VerifiableCredential&quot;
           ]
         }
       ]
     &quot;timestampAuthority&quot;: &quot;wesign&quot;,
     &quot;authoritySignature&quot;: &quot;MhmbHC1y3rfyb\/2sg+E2Uulczm8VDtmQ6VrU\/9ow4e4nP3lVUOv4Gz41pfBrJHnV4wQoUbQsCYpezFx5sdaUwUILV1I=HC1y3rfyb\/2sg+E2Uulczm8VDtmQ6VrU\/9ow4e4nP3lVUOv4Gz41pfBrJHnV4wQoUbQsCYpezFx5sdaUwUILV1I=HC1y3rfyb\/2sg+E2Uulczm8VDtmQ6VrU\/9ow4e4nP3lVUOv4Gz41pfBrJHnV4wQoUbQsCYpezFx5sdaUwUILV1I=a235==&quot;,
     &quot;timestamp&quot;: 151233113000,
     &quot;claimHash&quot;: &quot;0xe3f48648beee61d17de609d32af36ac0bf4d68a9352890b04d53841c4949bd13&quot;
     },
     &quot;context&quot;: &quot;https:\/\/github.com\/WeBankBlockchain\/WeIdentity\/blob\/master\/context\/v1&quot;,
     &quot;cptId&quot;: 108,
     &quot;expirationDate&quot;: 1567491842,
     &quot;id&quot;: &quot;ad5d5a54-4574-4b3b-b1df-9d0687b6a0ac&quot;,
     &quot;issuanceDate&quot;: 1567405359,
     &quot;issuer&quot;: &quot;did:weid:1:0x4e9a111867ed6370e1e23f7a79426f6649eb78c6&quot;,
     &quot;proof&quot;: {
       &quot;created&quot;: 1567405359,
       &quot;creator&quot;: &quot;did:weid:1:0x4e9a111867ed6370e1e23f7a79426f6649eb78c6#keys-0&quot;,
       &quot;salt&quot;: {
         &quot;credentialList&quot;: &quot;&quot;
       },
       &quot;signatureValue&quot;: &quot;HC1y3rfyb\/2sg+E2Uulczm8VDtmQ6VrU\/9ow4e4nP3lVUOv4Gz41pfBrJHnV4wQoUbQsCYpezFx5sdaUwUILV1I=&quot;,
       &quot;type&quot;: &quot;Secp256k1&quot;
     },
     &quot;type&quot;: [
       &quot;VerifiableCredential&quot;
     ]
   }
errorCode: 0
errorMessage: success
transactionInfo:null
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant CredentialPojoService
调用者-&gt;&gt;CredentialPojoService: 调用createTrustedTimestamp()
CredentialPojoService-&gt;&gt;CredentialPojoService: 入参非空、格式及合法性检查
opt 入参校验失败
CredentialPojoService--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成全部不披露的凭证并生成hash
CredentialPojoService-&gt;&gt;时间戳服务: 发送hash，生成时间戳
时间戳服务--&gt;&gt;CredentialPojoService: 返回时间戳
CredentialPojoService-&gt;&gt;CredentialPojoService: 生成时间戳凭证
CredentialPojoService--&gt;&gt;调用者: 返回凭证
        </div></div>
</div>
<div class="section" id="amopservice">
<h3>AmopService<a class="headerlink" href="#amopservice" title="永久链接至标题">¶</a></h3>
<div class="section" id="registercallback">
<h4>1. registerCallback<a class="headerlink" href="#registercallback" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称:com.webank.weid.rpc.AmopService.registerCallback
接口定义:void registerCallback(Integer directRouteMsgType, AmopCallback directRouteCallback)
接口描述: 注册AMOP回调处理。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.Integer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>directRouteMsgType</p></td>
<td><p>Integer</p></td>
<td><p>Y</p></td>
<td><p>AMOP消息类型</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.rpc.callback.AmopCallback</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>AmopCallback</p></td>
<td><p>处理消息的callback对象</p></td>
<td><p>机构需继承并且重写onPush(AmopCommonArgs arg)</p></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   无;</p>
</div>
<hr class="docutils" />
<div class="section" id="request">
<h4>2. request<a class="headerlink" href="#request" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AmopService.request
接口定义: ResponseData&lt;AmopResponse&gt; request(String toOrgId, AmopCommonArgs args)
接口描述: AMOP请求Server。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>toOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>目标机构编码</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.amop.AmopCommonArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>messageId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>消息编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>fromOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>消息来源机构编号</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>toOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>消息目标机构编号</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>message</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>请求body</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;AmopResponse&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>AmopResponse</p></td>
<td><p>AMOP响应</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.AmopResponse</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>AMOP消息响应body</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>业务结果编码</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>业务结果描述</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>messageId</p></td>
<td><p>String</p></td>
<td><p>消息编号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
</tbody>
</table>
</div>
<hr class="docutils" />
<div class="section" id="getpolicyandchallenge">
<h4>3. getPolicyAndChallenge<a class="headerlink" href="#getpolicyandchallenge" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AmopService.getPolicyAndChallenge
接口定义: ResponseData&lt;PolicyAndChallenge&gt; getPolicyAndChallenge(String orgId, Integer policyId, String targetUserWeId)
接口描述: 通过AMOP获取PolicyAndChallenge。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>toOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>目标机构编码</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>java.lang.Integer</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>policyId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>策略编号</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>java.lang.String</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>targetUserWeId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>需要被challenge的WeIdentity DID</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;PolicyAndChallenge&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>PolicyAndChallenge</p></td>
<td></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PolicyAndChallenge</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>presentationPolicyE</p></td>
<td><p>PresentationPolicyE</p></td>
<td><p>策略信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>challenge</p></td>
<td><p>Challenge</p></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.PresentationPolicyE</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>id</p></td>
<td><p>Integer</p></td>
<td><p>polcyId</p></td>
<td><p>策略编号</p></td>
</tr>
<tr class="row-odd"><td><p>orgId</p></td>
<td><p>String</p></td>
<td><p>机构编号</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>policyPublisherWeId</p></td>
<td><p>String</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>创建policy机构的WeIdentity DID</p></td>
</tr>
<tr class="row-even"><td><p>policy</p></td>
<td><p>Map&lt;Integer, ClaimPolicy&gt;</p></td>
<td><p>策略配置</p></td>
<td><p>key:CPTID, value:披露策略对象</p></td>
</tr>
<tr class="row-odd"><td><p>extra</p></td>
<td><p>Map&lt;String, String&gt;</p></td>
<td><p>扩展字段</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.base.Challenge</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>weId</p></td>
<td><p>String</p></td>
<td><p>WeIdentity DID</p></td>
<td><p>policy提供给指定的WeIdentity DID</p></td>
</tr>
<tr class="row-odd"><td><p>version</p></td>
<td><p>Integer</p></td>
<td><p>版本</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>nonce</p></td>
<td><p>String</p></td>
<td><p>随机字符串</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>POLICY_SERVICE_NOT_EXISTS</p></td>
<td><p>100701</p></td>
<td><p>policyService不存在</p></td>
</tr>
<tr class="row-even"><td><p>POLICY_SERVICE_CALL_FAIL</p></td>
<td><p>100702</p></td>
<td><p>policyService调用未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
</tbody>
</table>
</div>
<hr class="docutils" />
<div class="section" id="getencryptkey">
<h4>4. getEncryptKey<a class="headerlink" href="#getencryptkey" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.rpc.AmopService.getEncryptKey
接口定义: ResponseData&lt;GetEncryptKeyResponse&gt; getEncryptKey(String toOrgId, GetEncryptKeyArgs args)
接口描述: 通过AMOP获取密钥数据。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>toOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>目标机构编码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>args</p></td>
<td><p>GetEncryptKeyArgs</p></td>
<td><p>Y</p></td>
<td><p>密钥请求数据</p></td>
<td></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.amop.GetEncryptKeyArgs</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>keyId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>用于获取数据的Id</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>version</p></td>
<td><p>Version</p></td>
<td><p>Y</p></td>
<td><p>sdk版本信息</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>messageId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>消息Id</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>fromOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>数据来源机构</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>toOrgId</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>数据目标机构</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;GetEncryptKeyResponse&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>GetEncryptKeyResponse</p></td>
<td></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p>com.webank.weid.protocol.response.GetEncryptKeyResponse</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>encryptKey</p></td>
<td><p>String</p></td>
<td><p>密钥数据</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>错误码</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>错误描述</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>ENCRYPT_KEY_NOT_EXISTS</p></td>
<td><p>100700</p></td>
<td><p>无法获取秘钥</p></td>
</tr>
<tr class="row-even"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<hr class="docutils" />
<div class="section" id="jsontransportation">
<h3>JsonTransportation<a class="headerlink" href="#jsontransportation" title="永久链接至标题">¶</a></h3>
<div class="section" id="specify">
<h4>1. specify<a class="headerlink" href="#specify" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.JsonTransportation.specify
接口定义: JsonTransportation specify(List&lt;String&gt; verifierWeIdList)
接口描述: 指定transportation的认证者,用于权限控制。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.util.List&lt;java.lang.String&gt;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>verifierWeIdList</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>N</p></td>
<td><p>verifierWeId列表</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.suite.api.transportation.inf.JsonTransportation;</p>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">JsonTransportation</span> <span class="n">jsonTransportation</span> <span class="o">=</span><span class="n">TransportationFactory</span><span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">();</span>

<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
<span class="n">jsonTransportation</span> <span class="o">=</span> <span class="n">jsonTransportation</span><span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">);</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant JsonTransportation
participant WeIdService
participant 区块链
调用者-&gt;&gt;JsonTransportation: 调用specify()
JsonTransportation-&gt;&gt;JsonTransportation: 入参非空、格式及合法性检查
opt 入参校验失败
JsonTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
loop 遍历每个WeID
JsonTransportation-&gt;&gt;WeIdService: 判断WeID的合法性，以及存在性，调用isWeIdExist()方法
WeIdService-&gt;&gt;区块链: 查询该WeID是否存在
区块链--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;JsonTransportation: 返回查询结果
opt WeID不存在
JsonTransportation--&gt;&gt;调用者: 报错，提示WeID不存在
end
JsonTransportation-&gt;&gt;JsonTransportation: 放入verifier list里
end
JsonTransportation--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="serialize">
<h4>2. serialize<a class="headerlink" href="#serialize" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.JsonTransportation.serialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;String&gt; serialize(T object,ProtocolProperty property)
接口描述: 用于序列化对象,要求对象实现JsonSerializer接口。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>序列化后的字符串数据</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_DATA_INVALID</p></td>
<td><p>100805</p></td>
<td><p>协议数据无效</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-odd"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-even"><td><p>BASE_ERROR</p></td>
<td><p>160007</p></td>
<td><p>weId基础未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">));</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">));</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant JsonTransportation
调用者-&gt;&gt;JsonTransportation: 调用serialize()
JsonTransportation-&gt;&gt;JsonTransportation: 入参非空、格式及合法性检查
opt 入参校验失败
JsonTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
JsonTransportation-&gt;&gt;JsonTransportation: 拼装Json格式的协议头数据
JsonTransportation-&gt;&gt;JsonTransportation: 判断是采用加密方式还是非加密方式
opt 非加密方式
JsonTransportation-&gt;&gt;JsonTransportation: 将presentation原文放入协议里
end
opt 加密方式
JsonTransportation-&gt;&gt;EncodeProcessor: 调用encode方法
EncodeProcessor-&gt;&gt;EncodeProcessor: 采用AES算法，生成对称加密秘钥
EncodeProcessor-&gt;&gt;persistence: 保存至存储库里
persistence--&gt;&gt;EncodeProcessor: 返回
EncodeProcessor--&gt;&gt;JsonTransportation: 返回加密之后的presentation数据
JsonTransportation-&gt;&gt;JsonTransportation: 将presentation密文放入协议里
end
JsonTransportation-&gt;&gt;DataToolUtils: 调用objToJsonStrWithNoPretty()将协议序列化成Json数据
DataToolUtils--&gt;&gt;JsonTransportation:返回包含presentation的Json数据
JsonTransportation--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="deserialize">
<h4>3. deserialize<a class="headerlink" href="#deserialize" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.JsonTransportation.deserialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;T&gt; deserialize(String transString,Class&lt;T&gt; clazz)
接口描述: 用于反序列化对象,要求目标对象实现JsonSerializer接口。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>transString</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>clazz</p></td>
<td><p>Class&lt;T&gt;</p></td>
<td><p>Y</p></td>
<td><p>目标类型</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:  &lt;T extends JsonSerializer&gt; com.webank.weid.protocol.response.ResponseData&lt;T&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>反序列化后的对象</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>ENCRYPT_KEY_NOT_EXISTS</p></td>
<td><p>100700</p></td>
<td><p>无法获取秘钥</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_VERSION_ERROR</p></td>
<td><p>100802</p></td>
<td><p>协议版本错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_DATA_INVALID</p></td>
<td><p>100805</p></td>
<td><p>协议数据无效</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>BASE_ERROR</p></td>
<td><p>160007</p></td>
<td><p>weId基础未知异常</p></td>
</tr>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">String</span> <span class="n">transString</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="o">;</span>

<span class="c1">//原文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">transString</span><span class="o">,</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>

<span class="c1">//密文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">transString</span><span class="o">,</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
              sequenceDiagram
  participant 调用者
  participant JsonTransportation
  调用者-&gt;&gt;JsonTransportation: 调用deserialize()
  JsonTransportation-&gt;&gt;JsonTransportation: 入参非空、格式及合法性检查
  opt 入参校验失败
  JsonTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
  end
  JsonTransportation-&gt;&gt;DataToolUtils: 调用deserialize()方法，反序列化协议数据
  DataToolUtils--&gt;&gt;JsonTransportation:返回Json格式的协议数据
  JsonTransportation-&gt;&gt;JsonTransportation: 解析协议，判断是采用加密方式还是非加密方式
  opt 非加密方式
  JsonTransportation-&gt;&gt;DataToolUtils: 调用deserialize方法将协议里的presentation反序列化为对象
  DataToolUtils--&gt;&gt;JsonTransportation: 返回PresentationE对象
  end
  opt 加密方式
  JsonTransportation-&gt;&gt;EncodeProcessor: 调用decode方法
  EncodeProcessor-&gt;&gt;User Agent: 发送AMOP请求，获取对称加密秘钥
  User Agent--&gt;&gt;EncodeProcessor: 返回加密秘钥
  EncodeProcessor-&gt;&gt;EncodeProcessor: 解密协议数据
  EncodeProcessor--&gt;&gt;JsonTransportation: 返回解密后的presentation数据
  JsonTransportation-&gt;&gt;DataToolUtils: 调用deserialize方法将协议里的presentation反序列化
  DataToolUtils--&gt;&gt;JsonTransportation: 返回PresentationE对象presentation反序列化为对象
  end

JsonTransportation--&gt;&gt;调用者: 返回成功
        </div></div>
</div>
<hr class="docutils" />
<div class="section" id="qrcodetransportation">
<h3>QrCodeTransportation<a class="headerlink" href="#qrcodetransportation" title="永久链接至标题">¶</a></h3>
<div class="section" id="id32">
<h4>1. specify<a class="headerlink" href="#id32" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.QrCodeTransportation.specify
接口定义: JsonTransportation specify(List&lt;String&gt; verifierWeIdList)
接口描述: 指定transportation的认证者,用于权限控制。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.util.List&lt;java.lang.String&gt;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>verifierWeIdList</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>N</p></td>
<td><p>verifierWeId列表</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.suite.api.transportation.inf.JsonTransportation;</p>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">QrCodeTransportation</span> <span class="n">qrCodeTransportation</span> <span class="o">=</span><span class="n">TransportationFactory</span><span class="o">.</span><span class="na">newQrCodeTransportation</span><span class="o">();</span>

<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
<span class="n">JsonTransportation</span> <span class="n">jsonTransportation</span> <span class="o">=</span> <span class="n">qrCodeTransportation</span><span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">);</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant QrCodeTransportation
participant WeIdService
participant 区块链
调用者-&gt;&gt;QrCodeTransportation: 调用specify()
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 入参非空、格式及合法性检查
opt 入参校验失败
QrCodeTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
loop 遍历每个WeID
QrCodeTransportation-&gt;&gt;WeIdService: 判断WeID的合法性，以及存在性，调用isWeIdExist()方法
WeIdService-&gt;&gt;区块链: 查询该WeID是否存在
区块链--&gt;&gt;WeIdService: 返回查询结果
WeIdService--&gt;&gt;QrCodeTransportation: 返回查询结果
opt WeID不存在
QrCodeTransportation--&gt;&gt;调用者: 报错，提示WeID不存在
end
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 放入verifier list里
end
QrCodeTransportation--&gt;&gt;调用者: 返回成功
        </div></div>
<hr class="docutils" />
<div class="section" id="id33">
<h4>2. serialize<a class="headerlink" href="#id33" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.QrCodeTransportation.serialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;String&gt; serialize(T object,ProtocolProperty property)
接口描述: 用于序列化对象,要求对象实现JsonSerializer接口。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;String&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>String</p></td>
<td><p>序列化后的字符串数据</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_DATA_INVALID</p></td>
<td><p>100805</p></td>
<td><p>协议数据无效</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>id无效</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>BASE_ERROR</p></td>
<td><p>160007</p></td>
<td><p>weId基础未知异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newQrCodeTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">));</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newQrCodeTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">));</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
            sequenceDiagram
participant 调用者
participant QrCodeTransportation
调用者-&gt;&gt;QrCodeTransportation: 调用serialize()
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 入参非空、格式及合法性检查
opt 入参校验失败
QrCodeTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
end
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 拼装协议头数据
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 判断是采用加密方式还是非加密方式
opt 非加密方式
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 将presentation原文放入协议里
end
opt 加密方式
QrCodeTransportation-&gt;&gt;EncodeProcessor: 调用encode方法
EncodeProcessor-&gt;&gt;EncodeProcessor: 采用AES算法，生成对称加密秘钥
EncodeProcessor-&gt;&gt;persistence: 保存至存储库里
persistence--&gt;&gt;EncodeProcessor: 返回
EncodeProcessor--&gt;&gt;QrCodeTransportation: 返回加密之后的presentation数据
QrCodeTransportation-&gt;&gt;QrCodeTransportation: 将presentation密文放入协议里
end
QrCodeTransportation--&gt;&gt;调用者: 返回QRCode协议数据
        </div></div>
<hr class="docutils" />
<div class="section" id="id34">
<h4>3. deserialize<a class="headerlink" href="#id34" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.QrCodeTransportation.deserialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;T&gt; deserialize(String transString,Class&lt;T&gt; clazz)
接口描述: 用于反序列化对象,要求目标对象实现JsonSerializer接口。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>transString</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>clazz</p></td>
<td><p>Class&lt;T&gt;</p></td>
<td><p>Y</p></td>
<td><p>目标类型</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:  &lt;T extends JsonSerializer&gt; com.webank.weid.protocol.response.ResponseData&lt;T&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>反序列化后的对象</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>ENCRYPT_KEY_NOT_EXISTS</p></td>
<td><p>100700</p></td>
<td><p>无法获取秘钥</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_VERSION_ERROR</p></td>
<td><p>100802</p></td>
<td><p>协议版本错误</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_STRING_INVALID</p></td>
<td><p>100804</p></td>
<td><p>协议字符串无效</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>id无效</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>BASE_ERROR</p></td>
<td><p>160007</p></td>
<td><p>weId基础未知异常</p></td>
</tr>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">String</span> <span class="n">transString</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="o">;</span>

<span class="c1">//原文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newQrCodeTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">transString</span><span class="o">,</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>

<span class="c1">//密文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newQrCodeTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">transString</span><span class="o">,</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
</pre></div>
</div>
<p><strong>时序图</strong></p>

            <style>
            /* mermaid issue 527 workaround */
            .section {
                opacity: 1.0 !important;
            }
            </style>
            <div class="mermaid">
              sequenceDiagram
  participant 调用者
  participant QrCodeTransportation
  调用者-&gt;&gt;QrCodeTransportation: 调用deserialize()
  QrCodeTransportation-&gt;&gt;QrCodeTransportation: 入参非空、格式及合法性检查
  opt 入参校验失败
  QrCodeTransportation--&gt;&gt;调用者: 报错，提示参数不合法并退出
  end
  QrCodeTransportation-&gt;&gt;QrCodeTransportation: 解析协议，判断是采用加密方式还是非加密方式
  opt 非加密方式
  QrCodeTransportation-&gt;&gt;DataToolUtils: 调用deserialize方法将协议里的presentation反序列化为对象
  DataToolUtils--&gt;&gt;QrCodeTransportation: 返回PresentationE对象
  end
  opt 加密方式
  QrCodeTransportation-&gt;&gt;EncodeProcessor: 调用decode方法
  EncodeProcessor-&gt;&gt;User Agent: 发送AMOP请求，获取对称加密秘钥
  User Agent--&gt;&gt;EncodeProcessor: 返回加密秘钥
  EncodeProcessor-&gt;&gt;EncodeProcessor: 解密协议数据
  EncodeProcessor--&gt;&gt;QrCodeTransportation: 返回解密后的presentation数据
  QrCodeTransportation-&gt;&gt;DataToolUtils: 调用deserialize方法将协议里的presentation反序列化
  DataToolUtils--&gt;&gt;QrCodeTransportation: 返回PresentationE对象presentation反序列化为对象
  end

QrCodeTransportation--&gt;&gt;调用者: 返回成功
        </div></div>
</div>
<hr class="docutils" />
<div class="section" id="pdftransportation">
<h3>PdfTransportation<a class="headerlink" href="#pdftransportation" title="永久链接至标题">¶</a></h3>
<div class="section" id="id35">
<h4>1. specify<a class="headerlink" href="#id35" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.specify
接口定义: PdfTransportation specify(List&lt;String&gt; verifierWeIdList)
接口描述: 指定transportation的认证者,用于权限控制。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<p>java.util.List&lt;java.lang.String&gt;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>verifierWeIdList</p></td>
<td><p>List&lt;String&gt;</p></td>
<td><p>N</p></td>
<td><p>verifierWeId列表</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.suite.api.transportation.inf.PdfTransportation;</p>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">PPdfTransportation</span> <span class="n">pdfTransportation</span> <span class="o">=</span> <span class="n">TransportationFactory</span><span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">();</span>

<span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>
<span class="n">pdfTransportation</span> <span class="o">=</span> <span class="n">PdfTransportation</span><span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">);</span>
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id36">
<h4>2. serialize<a class="headerlink" href="#id36" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;byte[]&gt; serialize(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication);
接口描述: 用于序列化对象,要求对象实现JsonSerializer接口
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>WeID公私钥信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;byte[]&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>byte[]</p></td>
<td><p>序列化后PDF文件的byte数组</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN</p></td>
<td><p>100431</p></td>
<td><p>存证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_HASH_MISMATCH</p></td>
<td><p>100501</p></td>
<td><p>Evidence Hash不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PDF_TRANSFER_ERROR</p></td>
<td><p>100808</p></td>
<td><p>Pdf转换异常</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();;</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">);</span>
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id37">
<h4>3. serialize<a class="headerlink" href="#id37" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;Boolean&gt; serialize(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication,String outputPdfFilePath);
接口描述: 用于序列化对象并输出PDF文件,要求对象实现JsonSerializer接口
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>WeID公私钥信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>outputPdfFilePath</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>输出文件的路径</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>序列化生成文件的结果</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN</p></td>
<td><p>100431</p></td>
<td><p>存证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_HASH_MISMATCH</p></td>
<td><p>100501</p></td>
<td><p>Evidence Hash不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PDF_TRANSFER_ERROR</p></td>
<td><p>100808</p></td>
<td><p>Pdf转换异常</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();;</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">,</span><span class="s">&quot;./&quot;</span><span class="o">);</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">,</span><span class="s">&quot;./&quot;</span><span class="o">);</span>
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="serializewithtemplate">
<h4>4. serializeWithTemplate<a class="headerlink" href="#serializewithtemplate" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serializeWithTemplate
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;byte[]&gt; serializeWithTemplate(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication,String inputPdfTemplatePath);
接口描述: 用于序列化对象,要求对象实现JsonSerializer接口
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>WeID公私钥信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>inputPdfTemplatePath</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>指定模板位置</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;byte[]&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>byte[]</p></td>
<td><p>序列化后PDF文件的byte数组</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN</p></td>
<td><p>100431</p></td>
<td><p>存证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_HASH_MISMATCH</p></td>
<td><p>100501</p></td>
<td><p>Evidence Hash不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PDF_TRANSFER_ERROR</p></td>
<td><p>100808</p></td>
<td><p>Pdf转换异常</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serializeWithTemplate</span><span class="o">(</span>
            <span class="n">presentation</span><span class="o">,</span>
            <span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">),</span>
            <span class="n">weIdAuthentication</span><span class="o">,</span>
            <span class="s">&quot;./test-template.pdf&quot;</span><span class="o">);</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serializeWithTemplate</span><span class="o">(</span>
            <span class="n">presentation</span><span class="o">,</span>
            <span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">),</span>
            <span class="n">weIdAuthentication</span><span class="o">,</span>
            <span class="s">&quot;./test-template.pdf&quot;</span><span class="o">);</span>
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id38">
<h4>5. serializeWithTemplate<a class="headerlink" href="#id38" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.serializeWithTemplate
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;Boolean&gt; serializeWithTemplate(T object, ProtocolProperty property, WeIdAuthentication weIdAuthentication,String inputPdfTemplatePath,String outputPdfFilePath);
接口描述: 用于序列化对象,要求对象实现JsonSerializer接口
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>object</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>Y</p></td>
<td><p>待序列化对象</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>property</p></td>
<td><p>ProtocolProperty</p></td>
<td><p>Y</p></td>
<td><p>协议配置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>WeID公私钥信息</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>inputPdfTemplatePath</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>指定模板位置</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>outputPdfFilePath</p></td>
<td><p>String</p></td>
<td><p>Y</p></td>
<td><p>输出PDF文件位置</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:   com.webank.weid.protocol.response.ResponseData&lt;Boolean&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>Boolean</p></td>
<td><p>序列化生成文件的结果</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_ISSUER_MISMATCH</p></td>
<td><p>100403</p></td>
<td><p>issuerWeId跟Credential中的issuer不匹配</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_SIGNATURE_BROKEN</p></td>
<td><p>100431</p></td>
<td><p>存证签名异常</p></td>
</tr>
<tr class="row-odd"><td><p>CREDENTIAL_EVIDENCE_BASE_ERROR</p></td>
<td><p>100500</p></td>
<td><p>Evidence标准错误</p></td>
</tr>
<tr class="row-even"><td><p>CREDENTIAL_EVIDENCE_HASH_MISMATCH</p></td>
<td><p>100501</p></td>
<td><p>Evidence Hash不匹配</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_PROPERTY_ERROR</p></td>
<td><p>100801</p></td>
<td><p>协议配置异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PDF_TRANSFER_ERROR</p></td>
<td><p>100808</p></td>
<td><p>Pdf转换异常</p></td>
</tr>
<tr class="row-even"><td><p>WEID_AUTHORITY_INVALID</p></td>
<td><p>100109</p></td>
<td><p>授权信息无效</p></td>
</tr>
<tr class="row-odd"><td><p>WEID_PRIVATEKEY_DOES_NOT_MATCH</p></td>
<td><p>100106</p></td>
<td><p>私钥与WeIdentity DID不匹配</p></td>
</tr>
<tr class="row-even"><td><p>WEID_DOES_NOT_EXIST</p></td>
<td><p>100104</p></td>
<td><p>WeIdentity DID不存在</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>ILLEGAL_INPUT</p></td>
<td><p>160004</p></td>
<td><p>参数非法</p></td>
</tr>
<tr class="row-odd"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>

<span class="c1">//原文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serializeWithTemplate</span><span class="o">(</span>
            <span class="n">presentation</span><span class="o">,</span>
            <span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">),</span>
            <span class="n">weIdAuthentication</span><span class="o">,</span>
            <span class="s">&quot;./test-template.pdf&quot;</span><span class="o">,</span>
            <span class="s">&quot;./&quot;</span><span class="o">);</span>

<span class="c1">//密文方式调用</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result2</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serializeWithTemplate</span><span class="o">(</span>
            <span class="n">presentation</span><span class="o">,</span>
            <span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">),</span>
            <span class="n">weIdAuthentication</span><span class="o">,</span>
            <span class="s">&quot;./test-template.pdf&quot;</span><span class="o">,</span>
            <span class="s">&quot;./&quot;</span><span class="o">);</span>
</pre></div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="id39">
<h4>6. deserialize<a class="headerlink" href="#id39" title="永久链接至标题">¶</a></h4>
<p><strong>基本信息</strong></p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.deserialize
接口定义: &lt;T extends JsonSerializer&gt; ResponseData&lt;T&gt; deserialize(byte[] pdfTransportation, Class clazz, WeIdAuthentication weIdAuthentication);
接口描述: 用于反序列化对象,要求目标对象实现JsonSerializer接口。
</pre></div>
</div>
<p><strong>接口入参</strong>:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
<col style="width: 20%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>非空</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>pdfTransportation</p></td>
<td><p>byte[ ]</p></td>
<td><p>Y</p></td>
<td><p>待反序列化的包含PDF信息的byte数组</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>clazz</p></td>
<td><p>Class&lt;T&gt;</p></td>
<td><p>Y</p></td>
<td><p>目标类型</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>weIdAuthentication</p></td>
<td><p>WeIdAuthentication</p></td>
<td><p>Y</p></td>
<td><p>WeID公私钥信息</p></td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>接口返回</strong>:  &lt;T extends JsonSerializer&gt; com.webank.weid.protocol.response.ResponseData&lt;T&gt;;</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
<col style="width: 25%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>名称</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>说明</p></th>
<th class="head"><p>备注</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>errorCode</p></td>
<td><p>Integer</p></td>
<td><p>返回结果码</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>errorMessage</p></td>
<td><p>String</p></td>
<td><p>返回结果描述</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>result</p></td>
<td><p>&lt;T extends JsonSerializer&gt;</p></td>
<td><p>反序列化后的对象</p></td>
<td><p>业务数据</p></td>
</tr>
</tbody>
</table>
<p><strong>此方法返回code</strong></p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>enum</p></th>
<th class="head"><p>code</p></th>
<th class="head"><p>desc</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>SUCCESS</p></td>
<td><p>0</p></td>
<td><p>成功</p></td>
</tr>
<tr class="row-odd"><td><p>ENCRYPT_KEY_NOT_EXISTS</p></td>
<td><p>100700</p></td>
<td><p>无法获取秘钥</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_BASE_ERROR</p></td>
<td><p>100800</p></td>
<td><p>transportation基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_VERSION_ERROR</p></td>
<td><p>100802</p></td>
<td><p>协议版本错误</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_PROTOCOL_ENCODE_ERROR</p></td>
<td><p>100803</p></td>
<td><p>协议配置Encode异常</p></td>
</tr>
<tr class="row-odd"><td><p>TRANSPORTATION_PROTOCOL_DATA_INVALID</p></td>
<td><p>100805</p></td>
<td><p>协议数据无效</p></td>
</tr>
<tr class="row-even"><td><p>TRANSPORTATION_ENCODE_BASE_ERROR</p></td>
<td><p>100807</p></td>
<td><p>Encode基本未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>PRESISTENCE_DATA_KEY_INVALID</p></td>
<td><p>100901</p></td>
<td><p>dataKey无效</p></td>
</tr>
<tr class="row-even"><td><p>UNKNOW_ERROR</p></td>
<td><p>160003</p></td>
<td><p>未知异常</p></td>
</tr>
<tr class="row-odd"><td><p>BASE_ERROR</p></td>
<td><p>160007</p></td>
<td><p>weId基础未知异常</p></td>
</tr>
<tr class="row-even"><td><p>DATA_TYPE_CASE_ERROR</p></td>
<td><p>160008</p></td>
<td><p>数据转换异常</p></td>
</tr>
<tr class="row-odd"><td><p>DIRECT_ROUTE_REQUEST_TIMEOUT</p></td>
<td><p>160009</p></td>
<td><p>AMOP超时</p></td>
</tr>
<tr class="row-even"><td><p>DIRECT_ROUTE_MSG_BASE_ERROR</p></td>
<td><p>160010</p></td>
<td><p>AMOP异常</p></td>
</tr>
<tr class="row-odd"><td><p>SQL_EXECUTE_FAILED</p></td>
<td><p>160011</p></td>
<td><p>SQL执行异常</p></td>
</tr>
<tr class="row-even"><td><p>SQL_GET_CONNECTION_ERROR</p></td>
<td><p>160013</p></td>
<td><p>获取数据源连接异常</p></td>
</tr>
</tbody>
</table>
<p><strong>调用示例</strong></p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">weId</span> <span class="o">=</span> <span class="s">&quot;did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f&quot;</span><span class="o">;</span>
<span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">verifierWeIdList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;();</span>
<span class="n">verifierWeIdList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">weId</span><span class="o">);</span>

<span class="n">PresentationE</span> <span class="n">presentation</span><span class="o">;</span>
<span class="n">WeIdAuthentication</span> <span class="n">weIdAuthentication</span> <span class="o">=</span> <span class="k">new</span> <span class="n">WeIdAuthentication</span><span class="o">();</span>

<span class="c1">//序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">ORIGINAL</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="kt">byte</span><span class="o">[]&gt;</span> <span class="n">result1</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">serialize</span><span class="o">(</span><span class="n">presentation</span><span class="o">,</span><span class="k">new</span> <span class="n">ProtocolProperty</span><span class="o">(</span><span class="n">EncodeType</span><span class="o">.</span><span class="na">CIPHER</span><span class="o">),</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//原文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">resDeserialize</span> <span class="o">=</span>
    <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newPdfTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">response</span><span class="o">.</span><span class="na">getResult</span><span class="o">(),</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">,</span><span class="n">weIdAuthentication</span><span class="o">);</span>

<span class="c1">//密文方式调用反序列化</span>
<span class="n">ResponseData</span><span class="o">&lt;</span><span class="n">PresentationE</span><span class="o">&gt;</span> <span class="n">resDeserialize1</span> <span class="o">=</span>
   <span class="n">TransportationFactory</span>
        <span class="o">.</span><span class="na">newJsonTransportation</span><span class="o">()</span>
        <span class="o">.</span><span class="na">specify</span><span class="o">(</span><span class="n">verifierWeIdList</span><span class="o">)</span>
        <span class="o">.</span><span class="na">deserialize</span><span class="o">(</span><span class="n">response1</span><span class="o">.</span><span class="na">getResult</span><span class="o">(),</span><span class="n">PresentationE</span><span class="o">.</span><span class="na">class</span><span class="o">,</span><span class="n">weIdAuthentication</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
      
        <a href="../index.html" class="btn btn-neutral" title="WeIdentity JAVA SDK" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright (2018)Webank Co. Ltd.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script src="../_static/translations.js"></script>
        <script src="https://unpkg.com/mermaid@7.1.0/dist/mermaid.min.js"></script>
    

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>